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 58 remaining solutions by signing in and submitting your own entry
#59 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

59 active golfers, 140 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 / @janbundesmann

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

24
#19 - Daniel / @Daniel00288663

04/27/2017 at 02:21PM

24
#20 - James Houghton / @jamesthoughton

05/17/2017 at 12:00AM

24
#21 - Gurukandhamoorthi / @Gurukandhamoor1

07/14/2017 at 04:49PM

24
#22 - Turkey Man / @lvturkeyman

11/25/2017 at 08:29AM

24
#23 - DHM / @DHM29978992

05/15/2018 at 01:39AM

24
#24 - Mihai / @mihaicristiant

04/08/2019 at 10:54AM

24
#25 - Charlie OConor / @charlieoconor

09/06/2019 at 08:05PM

24
#26 - Hannes Käufler / @hanneskaeufler

07/05/2020 at 07:53PM

24
#27 - Jon Krause / @jkrause314

12/20/2020 at 08:12PM

24
#28 - Jean George / @JeanGeo20504212

06/03/2022 at 09:16AM

24
#29 - Janzen / @__Coos

10/01/2022 at 12:36PM

24
#30 - 0xf00ff00f / @0xf00ff00f

12/24/2022 at 02:41PM