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 58753af0f5ef5c0006000006

Change attribute to getter

Wrap attributes with a getter method.

Start file
function() {
  var a = thing.index < other.attribute;
  var b = thing.index < other.attribute;
  var c = thing.attribute < other.index;
  var d = thing.attribute < other.index;
}
End file
function() {
  var a = thing.get('index') < other.get('attribute');
  var b = thing.get('index') < other.get('attribute');
  var c = thing.get('attribute') < other.get('index');
  var d = thing.get('attribute') < other.get('index');
}

View Diff

2,5c2,5
<   var a = thing.index < other.attribute;
<   var b = thing.index < other.attribute;
<   var c = thing.attribute < other.index;
<   var d = thing.attribute < other.index;
---
>   var a = thing.get('index') < other.get('attribute');
>   var b = thing.get('index') < other.get('attribute');
>   var c = thing.get('attribute') < other.get('index');
>   var d = thing.get('attribute') < other.get('index');

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 23 remaining solutions by signing in and submitting your own entry
#24 Air Quality Test 8 / AirQualityTest8 - Score: 29 - 01/15/17 @ 10:14
:%s/\.\(\a*\)/.get('\1')/g<CR>ZZ

0 comments

#25 Antoine Leveugle[Ξ] / Denouche - Score: 31 - 01/11/17 @ 09:11
:%s/\v\.(\w<kPlus>)/\.get('\1')/g<CR>:x<CR>

0 comments

#26 Yann / yannstadnicki - Score: 34 - 02/22/17 @ 06:31
:%s/index\|attribute/get('&')/g<CR>ZZ

0 comments

#27 Justin / wyne - Score: 37 - 01/10/17 @ 20:05
:%s/index\|attribute/get('\0')/g<CR>:wq<CR>

0 comments

#28 Yongjoo Ji / msrband - Score: 39 - 01/12/17 @ 01:36
:f<BS>%s/index\|attribute/get('\0')/g<CR>:wq<CR>

0 comments

#29 Matt Walsh / wattmalsh - Score: 47 - 02/08/17 @ 07:21
:%s/\(thing\|other\)\.\(\a*\)/\1.get('\2')/g<CR>ZZ

0 comments

Created by: wyne

29 active golfers, 65 entries

Leaderboard (lowest score wins):
24
#1 - Sebastian / soapsurfer

01/10/2017 at 08:49PM

24
#2 - Smylers / Smylers2

01/10/2017 at 09:57PM

24
#3 - Urtica dioica / udioica

01/11/2017 at 01:20AM

24
#4 - Stanislav / prstad

01/11/2017 at 07:42AM

24
#5 - John Braxler / braxler

01/11/2017 at 02:53PM

24
#6 - Saki Gw / Sakigw

01/11/2017 at 03:23PM

24
#7 - 84shin / ssssww

01/11/2017 at 06:02PM

24
#8 - Jan Bundesmann / ixjab

01/12/2017 at 08:37AM

24
#9 - Matt Rasmus / _mattrasmus

01/12/2017 at 06:38PM

24
#10 - Михаил Доронин / Boris_B_London

01/12/2017 at 07:39PM

24
#11 - Craig Langford / cllangfo

01/16/2017 at 08:45PM

24
#12 - Adrian Goldwaser / AdrianGoldwaser

01/17/2017 at 10:44AM

24
#13 - Social Botolinum / SocialBot4

01/25/2017 at 11:35AM

24
#14 - Daniel Hogan / danielhogan21

01/27/2017 at 04:24AM

24
#15 - Zhihong Liu / pieapple03

02/23/2017 at 06:30AM

24
#16 - sijinyuan / sijinyuan

03/02/2017 at 02:15AM

24
#17 - Evgeny`s Kindle / EvgenyKindle

03/19/2017 at 11:10AM

24
#18 - Daniel Hjelm / dhjelm

03/21/2017 at 12:30AM

25
#19 - Cristian Lupașcu / clupasq

01/10/2017 at 08:43PM

25
#20 - Никита Канунников / NIikitaK

01/11/2017 at 12:13PM

25
#21 - Assaf Lavie / AssafLavie

01/12/2017 at 05:57PM

25
#22 - jack / jack28887741

02/23/2017 at 11:06AM

26
#23 - Michael Topal / h4ckt1c

01/27/2017 at 09:14AM

29
#24 - Air Quality Test 8 / AirQualityTest8

01/15/2017 at 10:14AM

31
#25 - Antoine Leveugle[Ξ] / Denouche

01/11/2017 at 09:11AM

34
#26 - Yann / yannstadnicki

02/22/2017 at 06:31AM

37
#27 - Justin / wyne

01/10/2017 at 08:05PM

39
#28 - Yongjoo Ji / msrband

01/12/2017 at 01:36AM

47
#29 - Matt Walsh / wattmalsh

02/08/2017 at 07:21AM