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 48 remaining solutions by signing in and submitting your own entry
#49 RobertT / @techrt2050 - Score: 45 - 09/06/13 @ 04:41
:%<<<<<<<<CR>:set sw=4<CR>:2,21><CR>?;<CR>n4I <Esc>n.n.n.n.ZZ

0 comments


Created by: @alimoeeny

49 active golfers, 76 entries

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

08/04/2014 at 07:38PM

16
#32 - Kristof Vannotten / @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

17
#37 - Nathan Wallace / @nathanmwallace

11/27/2013 at 03:16PM

17
#38 - kemar / @le_kemar

08/29/2014 at 04:57PM

18
#39 - RR Arnold III / @rra3

05/26/2013 at 05:53PM

18
#40 - Vinicius Souza / @vsouzas

05/30/2013 at 04:45PM

18
#41 - Nathan / @NathanHarperoni

05/31/2013 at 04:31PM

18
#42 - brett / @brettyukich

09/22/2013 at 09:56PM

18
#43 - Ricardo M. Vilchis / @ajkaanbal

07/18/2014 at 04:14PM

18
#44 - Carlos A HenrĂ­quez Q / @lagunex

01/19/2015 at 11:15AM

18
#45 - Charlie OConor / @charlieoconor

09/06/2019 at 07:43PM

21
#46 - curist / @curist

07/09/2013 at 04:53AM

23
#47 - Oliver Christ / @0liverChrist

10/15/2013 at 09:27PM

24
#48 - Matt Ryan / @mrevd

12/04/2014 at 12:53AM

45
#49 - RobertT / @techrt2050

09/06/2013 at 04:41AM