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

60 active golfers, 156 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