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

68 active golfers, 166 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

48
#4 - Peppa Pig / @PeppaPigSg

06/29/2024 at 08:41AM

49
#5 - Jean George / @JeanGeo20504212

03/10/2024 at 08:21PM

50
#6 - Bradd Szonye / @bszonye

07/13/2013 at 11:39AM

50
#7 - Jon Krause / @jkrause314

03/18/2016 at 05:30PM

51
#8 - Forrest Zeisler / @fzeisler

04/22/2013 at 03:21AM

52
#9 - Kerson Hsiao / @KersonHsiao

03/24/2013 at 09:40AM

52
#10 - 张文远 / @zhwenyuan

05/23/2013 at 08:11AM

52
#11 - Felix / @DoubleFelix_

02/24/2015 at 10:14AM

53
#12 - Édouard M'tou / @DouardM

02/13/2013 at 09:46PM

54
#13 - Øystein Walle / @oysteinwalle

02/28/2013 at 07:43AM

54
#14 - Carlos A Henríquez Q / @lagunex

01/19/2015 at 08:59AM

56
#15 - Vito / @GodFather

03/03/2013 at 09:19PM

57
#16 - Ben Zittlau / @benzittlau

04/21/2013 at 10:06PM

57
#17 - vimgolfer / @vimgolfer7

10/07/2019 at 01:38AM

58
#18 - Asmund / @herrasbe

02/14/2013 at 08:42PM

58
#19 - Joel Elkins / @dice_tea

03/04/2013 at 12:10AM

58
#20 - Chasetopher / @chasetopherlee

04/28/2013 at 10:27PM

58
#21 - RockerZZY / @rocker_zzy

06/21/2020 at 05:04AM

59
#22 - Daan Bakker / @dobakker

03/16/2013 at 09:21AM

59
#23 - Volodimir Barna / @RobertoUA

03/27/2013 at 08:21AM

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

08/12/2013 at 08:16PM

60
#25 - Gtranbot / @gtranbot

04/27/2013 at 01:51PM

63
#26 - Joonas Pihlajamaa / @jokkebk

03/15/2014 at 10:37AM

64
#27 - Ram Tamtam / @ramtamtamtam

07/02/2014 at 01:36PM

65
#28 - Daniel Lundin / @danielundin

02/12/2013 at 01:56PM

65
#29 - Joseph McDonald / @jots

05/06/2013 at 10:16PM

66
#30 - Runar / @runarfu

02/13/2013 at 07:28AM