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

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

64 active golfers, 163 entries

Solutions by @RPMiller:
25
#49 - Ryan Miller / @RPMiller

08/20/2025 at 08:28PM

26
#>51 - Ryan Miller / @RPMiller

08/20/2025 at 08:26PM

29
#>55 - Ryan Miller / @RPMiller

08/20/2025 at 08:24PM

31
#>56 - Ryan Miller / @RPMiller

08/20/2025 at 08:22PM

39
#>61 - Ryan Miller / @RPMiller

08/20/2025 at 08:04PM

46
#>61 - Ryan Miller / @RPMiller

08/20/2025 at 08:01PM