Real Vim ninjas count every keystroke - do you?

Pick a challenge, fire up Vim, and show us what you got.

Changelog, Rules & FAQ, updates: @vimgolf, RSS.

Your VimGolf key: please sign in

$ gem install vimgolf
$ vimgolf setup
$ vimgolf put 51a115429bada1000200001b

paste indent correction - JS

You copy some javascript code from a website and paste it into vim, it does not look good!

Start file
function AlbumCtrl($scope, $http) {
      $scope.url = 'http://onehungrymind.com/angular-album/images.json';
          $scope.images = [];
              $scope.imageCategories = [];
                  $scope.currentImage = {};

                      function handleImagesLoaded(data, status) {
                                $scope.images = data;
                                        $scope.currentImage = _.first($scope.images);
                                                $scope.imageCategories = _.uniq(_.pluck($scope.images, 'category'));
                                                    }

                          $scope.fetch = function () {
                                    $http.get($scope.url).success($scope.handleImagesLoaded);
                                        }

                              $scope.setCurrentImage = function (image) {
                                        $scope.currentImage = image;
                                            };

                                  $scope.fetch();
}

End file
function AlbumCtrl($scope, $http) {
    $scope.url = 'http://onehungrymind.com/angular-album/images.json';
    $scope.images = [];
    $scope.imageCategories = [];
    $scope.currentImage = {};

    function handleImagesLoaded(data, status) {
        $scope.images = data;
        $scope.currentImage = _.first($scope.images);
        $scope.imageCategories = _.uniq(_.pluck($scope.images, 'category'));
    }

    $scope.fetch = function () {
        $http.get($scope.url).success($scope.handleImagesLoaded);
    }

    $scope.setCurrentImage = function (image) {
        $scope.currentImage = image;
    };

    $scope.fetch();
}

View Diff

2,5c2,5
<       $scope.url = 'http://onehungrymind.com/angular-album/images.json';
<           $scope.images = [];
<               $scope.imageCategories = [];
<                   $scope.currentImage = {};
---
>     $scope.url = 'http://onehungrymind.com/angular-album/images.json';
>     $scope.images = [];
>     $scope.imageCategories = [];
>     $scope.currentImage = {};
7,11c7,11
<                       function handleImagesLoaded(data, status) {
<                                 $scope.images = data;
<                                         $scope.currentImage = _.first($scope.images);
<                                                 $scope.imageCategories = _.uniq(_.pluck($scope.images, 'category'));
<                                                     }
---
>     function handleImagesLoaded(data, status) {
>         $scope.images = data;
>         $scope.currentImage = _.first($scope.images);
>         $scope.imageCategories = _.uniq(_.pluck($scope.images, 'category'));
>     }
13,15c13,15
<                           $scope.fetch = function () {
<                                     $http.get($scope.url).success($scope.handleImagesLoaded);
<                                         }
---
>     $scope.fetch = function () {
>         $http.get($scope.url).success($scope.handleImagesLoaded);
>     }
17,19c17,19
<                               $scope.setCurrentImage = function (image) {
<                                         $scope.currentImage = image;
<                                             };
---
>     $scope.setCurrentImage = function (image) {
>         $scope.currentImage = image;
>     };
21c21
<                                   $scope.fetch();
---
>     $scope.fetch();

Solutions

The best way to learn is to practice. Below, you will find some of the solutions other golfers have entered. To unlock higher ranked solutions, submit your own entry which does as well or better than the solutions you can currently see - climb the ladder!

Check out these helpful resources to improve your Vim skills... Game on.

Unlock 58 remaining solutions by signing in and submitting your own entry
#59 Sylvain Dangin / @Sylvaner03 - Score: 88 - 02/24/21 @ 21:36
:%s/  /<BS><BS>.<BS> .*<BS><BS><BS><BS>.*  /    /g<CR>:%s/{\n/{\r    /g<CR><Up><Up><Up><Up><Up><Up><Up><Up><Up><Left><Left><Left><Home>i    <Down>    <Up><Up><Up><Up><Up><Up><Up><Up><BS><BS><BS><BS><Esc>:wq<CR>

0 comments


Created by: @alimoeeny

59 active golfers, 112 entries

Leaderboard (lowest score wins):
16
#31 - John Braxler / @braxler

08/04/2014 at 07:38PM

16
#32 - Kristof / @kristofv

09/08/2014 at 08:55PM

16
#33 - Felix / @DoubleFelix_

02/24/2015 at 10:19AM

16
#34 - Jon Krause / @jkrause314

01/15/2016 at 05:58PM

16
#35 - Yahyalexandre33 / @yahyalexandre33

03/14/2016 at 10:58PM

16
#36 - Clay Ratliff / @MulitfariousGuy

05/08/2016 at 06:20PM

16
#37 - roudens / @roudens2

02/20/2021 at 05:49AM

16
#38 - Alex / @AlexanderHeatl2

05/27/2022 at 05:45PM

16
#39 - z00master / @z00master

08/31/2022 at 03:57PM

16
#40 - Janzen / @__Coos

09/27/2022 at 10:23AM

16
#41 - Иван / @wansmer

05/05/2023 at 06:22AM

16
#42 - Peppa Pig / @PeppaPigSg

06/29/2024 at 07:23AM

16
#43 - nickGPT / @nickandbro

08/28/2024 at 06:35PM

17
#44 - Nathan Wallace / @nathanmwallace

11/27/2013 at 03:16PM

17
#45 - kemar / @le_kemar

08/29/2014 at 04:57PM

17
#46 - rappenstein2 / @rappenstein2

01/16/2022 at 08:44PM

18
#47 - RR Arnold III / @rra3

05/26/2013 at 05:53PM

18
#48 - Vinicius Souza / @vsouzas

05/30/2013 at 04:45PM

18
#49 - Nathan / @NathanHarperoni

05/31/2013 at 04:31PM

18
#50 - brett / @brettyukich

09/22/2013 at 09:56PM

18
#51 - Ricardo M. Vilchis / @ajkaanbal

07/18/2014 at 04:14PM

18
#52 - Carlos A Henríquez Q / @lagunex

01/19/2015 at 11:15AM

18
#53 - Charlie OConor / @charlieoconor

09/06/2019 at 07:43PM

21
#54 - curist / @curist

07/09/2013 at 04:53AM

23
#55 - Oliver Christ / @0liverChrist

10/15/2013 at 09:27PM

24
#56 - Matt Ryan / @mrevd

12/04/2014 at 12:53AM

32
#57 - Olivier Bégassat / @zk_evm

06/15/2023 at 02:35PM

45
#58 - RobertT / @techrt2050

09/06/2013 at 04:41AM

88
#59 - Sylvain Dangin / @Sylvaner03

02/24/2021 at 09:36PM