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 63 remaining solutions by signing in and submitting your own entry
#64 Shaw / @Helionitial - Score: 75 - 05/22/22 @ 17:59
:%s/\(thing|<BS>.<BS>\.<BS><BS>|other|<BS>)<BS><BS><BS><BS><BS><BS><BS>\><BS>|other\)\.\(\a*\)/\1.get('\2')/g<<BS><CR>ZZ

0 comments


Created by: @wyne

64 active golfers, 163 entries

Leaderboard (lowest score wins):
24
#31 - moh ayaya / @AyayaMoh

09/27/2023 at 04:18PM

24
#32 - James / @Dronak

10/13/2023 at 03:22PM

24
#33 - Luoyb / @Luoyb

11/17/2023 at 06:01AM

24
#34 - Peppa Pig / @PeppaPigSg

07/02/2024 at 09:50AM

24
#35 - zhs / @ZH-S

04/27/2025 at 02:39AM

24
#36 - Brian Rhees / @brhees

05/08/2025 at 06:54PM

24
#37 - Taylor Allred / @tcallred

05/08/2025 at 06:55PM

25
#38 - Cristian Lupașcu / @clupasq

01/10/2017 at 08:43PM

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

01/11/2017 at 12:13PM

25
#40 - we’re going to need a bigger bot / @assaflavie

01/12/2017 at 05:57PM

25
#41 - jack / @jack28887741

02/23/2017 at 11:06AM

25
#42 - Ben Hill / @KaizenSoze70

09/27/2017 at 06:20PM

25
#43 - Maricris Bonzo / @seemcat

10/17/2017 at 03:11AM

25
#44 - Norbert / @mullno

07/02/2018 at 06:15PM

25
#45 - albalitz / @_albalitz

06/26/2019 at 02:43PM

25
#46 - Michel Viktor / @tomkpz

07/30/2021 at 05:31AM

25
#47 - Alex / @AlexanderHeatl2

05/30/2022 at 10:04PM

25
#48 - キムラ・OPEL・ユウジ / @kimurayuuji79

11/07/2022 at 12:26AM

25
#49 - Ryan Miller / @RPMiller

08/20/2025 at 08:28PM

26
#50 - Michael Topal / @h4ckt1c

01/27/2017 at 09:14AM

26
#51 - jonas-grobe / @jonas-grobe

02/03/2024 at 09:41PM

27
#52 - RockerZZY / @rocker_zzy

07/31/2020 at 03:35AM

29
#53 - Air Quality Test 8 / @AirQualityTest8

01/15/2017 at 10:14AM

29
#54 - Benoit Bou / @3enoit3

06/18/2017 at 07:30AM

29
#55 - vimgolfaccfekxh / @vimgolfaccfekxh

10/23/2022 at 01:57PM

31
#56 - Antoine Leveugle / @Denouche

01/11/2017 at 09:11AM

33
#57 - @grhkm@infosec.exchange / @grhkm21

12/20/2022 at 11:12AM

33
#58 - nickGPT / @nickandbro

08/28/2024 at 02:58AM

34
#59 - Yann / @yannstad

02/22/2017 at 06:31AM

37
#60 - Justin Wyne / @wyne

01/10/2017 at 08:05PM