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

Unlock 8 remaining solutions by signing in and submitting your own entry
Created by: @wyne

59 active golfers, 140 entries

Solutions by @tomkpz:
25
#43 - Michel Viktor / @tomkpz

07/30/2021 at 05:31AM

26
#>46 - Michel Viktor / @tomkpz

07/30/2021 at 05:31AM

27
#>48 - Michel Viktor / @tomkpz

07/30/2021 at 05:30AM

29
#>50 - Michel Viktor / @tomkpz

07/30/2021 at 05:29AM

31
#>52 - Michel Viktor / @tomkpz

07/30/2021 at 05:29AM

34
#>55 - Michel Viktor / @tomkpz

07/30/2021 at 05:28AM

35
#>55 - Michel Viktor / @tomkpz

07/30/2021 at 05:28AM

38
#>56 - Michel Viktor / @tomkpz

07/30/2021 at 05:27AM