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 @brhees:

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

64 active golfers, 163 entries

Solutions by @brhees:
24
#36 - Brian Rhees / @brhees

05/08/2025 at 06:54PM

30
#>55 - Brian Rhees / @brhees

05/01/2025 at 06:55PM

34
#>59 - Brian Rhees / @brhees

05/01/2025 at 06:48PM

35
#>59 - Brian Rhees / @brhees

05/01/2025 at 06:47PM

47
#>62 - Brian Rhees / @brhees

05/01/2025 at 06:43PM