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 47 remaining solutions by signing in and submitting your own entry
#48 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

48 active golfers, 75 entries

Leaderboard (lowest score wins):
16
#1 - Urtica dioica / @udioica

05/25/2013 at 08:10PM

16
#2 - mnx / @mnxx

05/25/2013 at 08:24PM

16
#3 - Kai Yuan / @kentyuan

05/25/2013 at 08:53PM

16
#4 - r00tine / @r00tine

05/25/2013 at 09:03PM

16
#5 - Marco Hinz / @_mhinz_

05/25/2013 at 09:06PM

16
#6 - Joshua Draper / @JoshuaBDraper

05/25/2013 at 09:32PM

16
#7 - Nathan Bouscal / @nbouscal

05/26/2013 at 04:45AM

16
#8 - Sebastian Kusnier / @skusnier

05/26/2013 at 03:07PM

16
#9 - Petro Тrouq / @zulolosi

05/26/2013 at 07:13PM

16
#10 - Frank Dinoff / @FDinoff

05/28/2013 at 02:42AM

16
#11 - Richard John Soni / @richsoni

05/30/2013 at 05:42PM

16
#12 - Booberius / @booberius

05/31/2013 at 02:34PM

16
#13 - Nikita Leshenko / @nikita_l

06/01/2013 at 11:35AM

16
#14 - Aaron Bieber / @aaronbieber

06/02/2013 at 01:42PM

16
#15 - Al / @96258

06/06/2013 at 04:01AM

16
#16 - Jim / @BLSJim

06/10/2013 at 12:07AM

16
#17 - Spikes / @SpikesDivZero

06/10/2013 at 02:36PM

16
#18 - Javier Blanco / @jbgutierrez

06/20/2013 at 11:24PM

16
#19 - Norm Fasey / @DeathRay1977

06/21/2013 at 03:57PM

16
#20 - powertomato / @powertomato

06/27/2013 at 09:37PM

16
#21 - moo goo / @m00g000

07/02/2013 at 01:26PM

16
#22 - Woojung Kim 김우중 / @_kimwz

07/13/2013 at 12:30AM

16
#23 - Bradd Szonye / @bszonye

07/13/2013 at 08:43AM

16
#24 - Ingo / @ist3fani

07/29/2013 at 04:09PM

16
#25 - ———đίxίє—flαтlίиє——— / @_dixie_flatline

07/31/2013 at 03:44AM

16
#26 - cj / @cj01101

08/17/2013 at 07:38PM

16
#27 - James / @Dronak

09/12/2013 at 08:11PM

16
#28 - Joonas Pihlajamaa / @jokkebk

03/27/2014 at 09:41AM

16
#29 - Nolen Royalty / @NolenRoyalty

05/08/2014 at 03:05AM

16
#30 - Caek / @Caek_

07/15/2014 at 01:43AM