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 by @Caek_:

Unlock 1 remaining solutions by signing in and submitting your own entry
Created by: @alimoeeny

59 active golfers, 112 entries

Solutions by @Caek_:
16
#30 - Caek / @Caek_

07/15/2014 at 01:43AM