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 511991607729fb0002000003

Refactor arguments into object argument

A relatively common Javascript refactoring.

Start file
function foo(hello, world,
             how, are,
             you) {
}
End file
function foo(parameters) {
    var hello = parameters.hello;
    var world = parameters.world;
    var how = parameters.how;
    var are = parameters.are;
    var you = parameters.you;
}

View Diff

1,3c1,6
< function foo(hello, world,
<              how, are,
<              you) {
---
> function foo(parameters) {
>     var hello = parameters.hello;
>     var world = parameters.world;
>     var how = parameters.how;
>     var are = parameters.are;
>     var you = parameters.you;

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 47 remaining solutions by signing in and submitting your own entry
#48 DOUG BLACK / dougblackio - Score: 77 - 04/07/13 @ 22:08
JJ"kdi)iparameters<Esc>"oyiwo<Esc>"kp:s/, /<C-V><CR>/g<CR>qaywi    var <Esc>A = <Esc>"opa.<Esc>pa;<Esc>k0q4@aZZ

0 comments

#49 RR Arnold III / rra3 - Score: 77 - 05/26/13 @ 14:49
JJ"kdi)iparameters<Esc>"pyiwo<Esc>"kp:s/, /<C-V><CR>/g<CR>qaywi    var <Esc>A = <Esc>"ppa.<Esc>pa;<Esc>k0q4@aZZ

0 comments

#50 brett / brettyukich - Score: 78 - 09/22/13 @ 08:42
f("1ci(parameters<Esc>"2ybj"1PVG3<qq"3yeivar <Esc>ea = <C-R>2s.<C-R>3;<Del><Del><CR><Esc>q4@qi}<Esc>k<C-V>4kI    <Esc><Esc>ZZ

0 comments

#51 Kristian Lewis Jones / klj613 - Score: 82 - 03/01/13 @ 23:52
JJci(parameters<Esc>o<Esc>p0i    <Right><Esc>qpceu<BS><Esc>uivar <Esc>ei<Right> = parameters.<Esc>pi<Right><Del><Del>;<CR><Right><Esc>q@p@p@p@pi}<Esc>ZZ

0 comments

#52 Oliver Christ / 0liverChrist - Score: 85 - 10/04/13 @ 21:57
:%s/,/\r/g<CR>dd3Gddkkiparameters) {<CR>VT<BS><BS><Esc>V6G<.qai    var <Esc> c<Esc>ywA = p<C-P>.;<Esc>hp+q4@akf)xxxZZ

0 comments

#53 Phil / ischi - Score: 86 - 02/20/13 @ 21:28
f(ci)parameters<Esc>:pu<CR>:2j3<CR>i    <Esc>lqqivar <Esc>lvwhyhpa = p<C-N>.<Esc>f,r;a<CR><Esc>lq3@qivar <Esc>A = p<C-N>.y<C-N>;<Esc>ZZ

0 comments

#54 xRyanxBrutalityx / xHainingx - Score: 93 - 02/13/13 @ 00:48
fhd/)<CR>qpiparameters<Esc>qo<Esc>pqsf,xr<CR><Esc>;xq<Down>@s3<Up>bqayw@pa.<End>;<Esc>^ivar = <Left><Left><Esc>pa <End><Esc>wq4@a=gg<Down><C-V>4<Down>x<C-V>4<Down>I    <Esc><Esc>ZZ

0 comments

#55 Pradeep Kumar / pradeep6kumar - Score: 99 - 02/13/13 @ 04:41
f(di(iparameters) {<CR><CR><Esc>kp:2,4s/\v( +)?(\w+),?\1?/var \2 = parameters.\2;\r/g<CR>:4d|6d|7d<CR>k<C-V>4k$I <Esc>...ZZ

0 comments

#56 teo danciu / teozaurus - Score: 127 - 10/17/13 @ 02:44
JJci)parameters<Esc>bywo<Esc>i    var hello = <C-R>".hello;<CR>var world = <C-R>".world;<CR>var how = <C-R>".how;<CR>var are = <C-R>".are;<CR>var you = <C-R>".you;<Esc>:x<CR>

0 comments

#57 Satish Eerpini / satisheerpini - Score: 165 - 03/01/13 @ 23:54
/(<CR>"ayi(:s/(.*/(parameters) {/g<CR><Down>ddddO<Esc>"ap:%s/./\r/g<CR><Esc>u:<Up><Left><Left><Left><Left><Left><BS>,<CR>:%s/( )*(<BS><BS><BS><BS><BS>\( \)*\(.*\)/\2/g<CR><Up><Up>dd<Up><Up><Up>dd<Up><Up>:s/.*/    var & = parameters.&;/g<CR><Down>:<Up><CR><Down>:<Up><CR><Down>:<Up><CR><Down>:<Up><CR>:wq<BS><BS>x<CR>

0 comments

#58 Pamela / pamcdm - Score: 165 - 07/11/14 @ 02:47
<Esc>/(<CR><Right>di)iparameters<Esc>op<Esc>up<Esc>uo<Esc>pivr<BS><BS>    var <Esc>ea = parameters.hello;<CR><Up><Esc>yypppp/<Esc>hell<Esc>/hello<CR>nnncwworld<Esc>n.<Esc>ncwhow<Esc>n.<Esc>ncware<Esc>n.<Esc>ncwyou<Esc>n.<Esc>nnnn:7<CR>v<Down><Down>ee<Left><Left>d<BS><BS><BS>}<Esc>}i<BS><BS><BS><BS><CR>}<Esc>:x<CR>

0 comments

#59 shock_one / shock_one - Score: 263 - 08/15/14 @ 20:13
JJci(paramer<BS>ters<Esc>o<Esc>p?<BS>:s/,/<RC<BS><BS>CR>/g<CR>u/<BS>:s/,/CR/g<CR>u/<BS>:s/,/<c-r><Esc>?<C-R><Esc><Esc><Esc>:<C-R><C-R><Esc><Esc>s/<Esc>u:s/,/<c-r>/g<CR>u:s/,/\r/g<CR>kkkkVjjjj<Esc><Esc>kkkkVg6:6<CR>kkkkkVjjjj<Esc>kkkkV:<BS><BS><BS><BS><BS>6<CR>kkkkVjjjj<Esc><Esc>kkkkqqI<Esc>I<Esc><Esc>qqqI<Esc><Esc><Esc><Esc>qus/<Esc>us<Esc>u:s/, /\r/g<CR>qqIvar <Esc>lyeA = p<Tab><BS>arameters.<Esc>pA;<Esc>qk@qk@qk@qk@qI    <Esc>j.j.j.j.<Esc>:x<CR>

0 comments

Created by: blingcoder

59 active golfers, 155 entries

Leaderboard (lowest score wins):
48
#1 - Urtica dioica / udioica

02/12/2013 at 02:04AM

48
#2 - Petro Тrouq / zulolosi

02/17/2013 at 08:28AM

48
#3 - John Braxler / braxler

05/15/2014 at 06:22PM

50
#4 - Bradd Szonye / bszonye

07/13/2013 at 11:39AM

50
#5 - Jon Krause / jkrause314

03/18/2016 at 05:30PM

51
#6 - Forrest Zeisler / fzeisler

04/22/2013 at 03:21AM

52
#7 - Kerson Hsiao / KersonHsiao

03/24/2013 at 09:40AM

52
#8 - wushexu / wushexu

05/23/2013 at 08:11AM

52
#9 - Felix / DoubleFelix_

02/24/2015 at 10:14AM

53
#10 - Édouard M'tou / DouardM

02/13/2013 at 09:46PM

54
#11 - Øystein Walle / oysteinwalle

02/28/2013 at 07:43AM

54
#12 - Carlos A Henríquez Q / lagunex

01/19/2015 at 08:59AM

56
#13 - Vito / GodFather

03/03/2013 at 09:19PM

57
#14 - Ben Zittlau / benzittlau

04/21/2013 at 10:06PM

58
#15 - Asmund / herrasbe

02/14/2013 at 08:42PM

58
#16 - Joel Elkins / dice_tea

03/04/2013 at 12:10AM

58
#17 - Chasetopher / chasetopherlee

04/28/2013 at 10:27PM

59
#18 - Daan Bakker / dobakker

03/16/2013 at 09:21AM

59
#19 - Volodimir Barna / RobertoUA

03/27/2013 at 08:21AM

59
#20 - Гребенщиков Максим / Aetet

08/12/2013 at 08:16PM

60
#21 - Gtranbot / gtranbot

04/27/2013 at 01:51PM

63
#22 - Joonas Pihlajamaa / jokkebk

03/15/2014 at 10:37AM

64
#23 - Ram Tamtam / ramtamtamtam

07/02/2014 at 01:36PM

65
#24 - Daniel Lundin / danielundin

02/12/2013 at 01:56PM

65
#25 - Joseph McDonald / jots

05/06/2013 at 10:16PM

66
#26 - Runar / runarfu

02/13/2013 at 07:28AM

67
#27 - Vim Golfer / vimgolfern00b

02/12/2013 at 05:51AM

67
#28 - Piotr Lewicki / lewiatan11

12/11/2017 at 11:04AM

68
#29 - Jason Wolf / zephyr_wolf

02/12/2013 at 02:41PM

68
#30 - Christopher Harrison / Xophmeister

02/13/2013 at 04:45PM

68
#31 - Oscar Friberg / oscfri

02/13/2013 at 10:41PM

68
#32 - Aaron Bieber / aaronbieber

06/02/2013 at 09:14PM

68
#33 - ltn614 / ltn614

10/08/2015 at 08:51AM

69
#34 - Kai Yuan / kentyuan

02/21/2013 at 03:26PM

70
#35 - Zach Kelling / zeekay

02/23/2013 at 07:13PM

70
#36 - David Elentok / elentok

05/09/2013 at 08:37AM

71
#37 - Woojung Kim 김우중 / _kimwz

07/15/2013 at 05:07AM

72
#38 - sfoo / sfoo

02/23/2013 at 11:29PM

72
#39 - 전영식 / garam111

02/28/2013 at 04:48AM

72
#40 - ict / ict_42

03/03/2013 at 05:37PM

72
#41 - CY / wongcy0

03/18/2013 at 06:57AM

72
#42 - cj / cj01101

08/08/2013 at 09:05PM

74
#43 - Axel Tetzlaff / TheAxelerator

05/12/2013 at 01:12PM

75
#44 - Ravi S Sinha / ambidextrousTx

02/12/2013 at 04:30AM

76
#45 - Rubén Laguna / ecerulm

02/20/2013 at 10:14PM

76
#46 - Corey Glynn / albedoa

04/08/2013 at 09:55PM

76
#47 - James / Dronak

09/25/2014 at 11:11PM

77
#48 - DOUG BLACK / dougblackio

04/07/2013 at 10:08PM

77
#49 - RR Arnold III / rra3

05/26/2013 at 02:49PM

78
#50 - brett / brettyukich

09/22/2013 at 08:42AM

82
#51 - Kristian Lewis Jones / klj613

03/01/2013 at 11:52PM

85
#52 - Oliver Christ / 0liverChrist

10/04/2013 at 09:57PM

86
#53 - Phil / ischi

02/20/2013 at 09:28PM

93
#54 - xRyanxBrutalityx / xHainingx

02/13/2013 at 12:48AM

99
#55 - Pradeep Kumar / pradeep6kumar

02/13/2013 at 04:41AM

127
#56 - teo danciu / teozaurus

10/17/2013 at 02:44AM

165
#57 - Satish Eerpini / satisheerpini

03/01/2013 at 11:54PM

165
#58 - Pamela / pamcdm

07/11/2014 at 02:47AM

263
#59 - shock_one / shock_one

08/15/2014 at 08:13PM