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