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 4d1a522ea860b7447200010b

Braces or Brackets?

Someone forgot whether to use braces or brackets and you have to clean up their code!

Start file
var some_function = function {arg1, arg2} [
	var some_array = (1, 2, 3, 4, 'foo');
	for {var i in some_array} (
		console.log(some_array, [{1 + (8 / 2)}, 'hello (world)');
	)
];
End file
var some_function = function (arg1, arg2) {
	var some_array = [1, 2, 3, 4, 'foo'];
	for (var i in some_array) {
		console.log(some_array, [(1 + (8 / 2)), 'hello (world)');
	}
};

View Diff

1,6c1,6
< var some_function = function {arg1, arg2} [
<       var some_array = (1, 2, 3, 4, 'foo');
<       for {var i in some_array} (
<               console.log(some_array, [{1 + (8 / 2)}, 'hello (world)');
<       )
< ];
---
> var some_function = function (arg1, arg2) {
>       var some_array = [1, 2, 3, 4, 'foo'];
>       for (var i in some_array) {
>               console.log(some_array, [(1 + (8 / 2)), 'hello (world)');
>       }
> };

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 185 remaining solutions by signing in and submitting your own entry
#186 David Fonseca / ddfonseca6 - Score: 51 - 10/09/16 @ 00:56
f{r(f}r)f[r{jlr]F(r[jF{r(f}r)llr{jf{r(f}r)jr}jhr}ZZ

0 comments


#187 Rob Ciaccio / RobertoCalavera - Score: 52 - 01/16/11 @ 08:47
:%s/{/(/g<CR>:<Up><Left><Left><Left><Left><BS>}<Right><Del>)<CR>:<Esc>1G$r{jlr]%F(r[j$r{jjr}jhr}ZZ

0 comments


#188 Craig H. Anderson / CootCraig - Score: 52 - 04/18/11 @ 15:41
f{r(f}r)llr{/(<CR>r[f)r]/{<CR>r(f}r)llr{jf{r(f}r)jr}jhr}ZZ

0 comments


#189 Mikhail Korepanov / PanyaKor - Score: 52 - 06/13/11 @ 13:33
f{r(f}r)2lr{jlr]F(r[j$r{2hr)F{r(jf{r(f}r)jr}jhr}:wq<CR>

0 comments


#190 mnx / mnxx - Score: 52 - 06/04/12 @ 21:59
/[(){}[]]*<CR>r(nr)nr{nr[nr]nr(nr)nr{nnnr(3nr)jr}jhr}ZZ

0 comments


#191 Dave Ingram / dmi - Score: 52 - 11/21/12 @ 18:31
f{r(f}r)f[r{jF(r[f)r]jF{r(f}r)f(r{jf{r(f}r)jr}jhr}ZZ

0 comments


#192 くま55 / kumack55 - Score: 52 - 04/03/13 @ 12:07
:%s{<BS>/{/(/g<CR>:<Up><Left><Left><BS>)<Left><Left><BS>}<CR>kkk$r{jlr]F(r[jf(r{jjr}jhr}ZZ

0 comments


#193 Dave / zzdave13 - Score: 53 - 08/02/11 @ 20:16
/[][{}()]<NL>r(nr)r<Esc>nr{nr[nr]nr(nr)nr{nnnr(nnnr)<NL>r}nr}ZZ

0 comments


#194 Daniel Harrington / rubiii - Score: 53 - 12/10/11 @ 19:42
f{r(f}r)f[r{jF(r[f)r]jF{r(f}r)f(r{jf{r(f}r)jr}jhr}:x<CR>

0 comments


#195 Bernhard Tausch / tauschb - Score: 53 - 03/08/13 @ 14:13
/[{\[\]}()]<CR>r(nr)nr{nr[nr]nr(nr)nr{3nr(3nr)4nr}nr}:x<CR>

0 comments


#196 alex scott / 4l3xsc0tt - Score: 54 - 12/30/10 @ 02:41
:%s/{\(.*\)}/(\1)<CR>jr}jhr}kkk%4%jj$r{kF(r[f)r]k$r{ZZ

0 comments


#197 jacobangel / jacobangel - Score: 54 - 12/31/10 @ 08:15
f{r(f}r)wr{jl%r[f)r]jr{jjr}jhr}3Gf{r(f}r)jf[R[(<Esc>f}r)ZZ

0 comments


#198 Dezső Zoltán / zakiazigazi - Score: 54 - 01/22/11 @ 07:24
f{r(%f}r)$r{{2f(jf(r[f)r]jr{F{r(f}r)jf{r(f}r)jr}jhr}ZZ

0 comments


#199 TchiKong / tchikong - Score: 54 - 01/29/11 @ 13:06
$r{<Left><Left>%r(<C-O>r)<Down><Right><Right><Right>%r[<C-O>r)r]<Down><Left><Left>%r(<C-O>r)<Right><Right>%r}<C-O>r{<Down>7<Right>%r)<C-O>r(Gr}ZZ

0 comments


#200 Gowtham Madhava / gowthamgowtham - Score: 54 - 07/02/12 @ 16:52
f{r(f}r)f[r{<Down><Esc><Esc>f)r]F(r[<Down>f}r)F{r(f(r{<Down>f{r(f}r)<Down>r}<Down><Left>r}ZZ

0 comments


#201 Manuel Meilinger / MMeilinger - Score: 54 - 03/08/13 @ 14:25
f{r(f}r)wr{jl%r[f)r]jr{jjr}jhr}3Gf{r(f}r)jf[R[(<Esc>f}r)ZZ

0 comments


#202 Fred Nias / frednias - Score: 55 - 12/30/10 @ 11:37
/{<CR>r(n.n./}<CR>.r)n.n./(<CR>NNr[nnr{/)<CR><Down>r{r}nnr]k$r{Gr}:wq<CR>

0 comments


#203 Adelar S. Queiróz / adelarsq - Score: 55 - 11/25/12 @ 01:26
f{r(f}r)f[r{jF(r[f)r]jF{r(f}r)f(r{jf[r[lr(f}r)jr}jhr}ZZ

0 comments


#204 René Scheibe / renescheibe - Score: 55 - 03/08/13 @ 14:16
/[\[\](){}]<CR>r(nr)5n.7n.nnnnr}n.3nr{nr[nr]nr(nnr{3nr(:x<CR>

0 comments


#205 drio / drio - Score: 56 - 12/29/10 @ 15:35
f{r(f}r)wr{j0f(r[f)r]jr{F}r)F{(jjf{r(jf{r(f}r)jr}jhr}:x<CR>

0 comments


#206 Son of Bongo / bpcode - Score: 56 - 08/26/12 @ 03:32
:%s/{/(/g<CR>:<Up><Left><Left><BS>)<Left><Left><BS>}<CR>[\k)X}I}<Esc>klr}k$hr<Esc>kr{kF(r[f)r]kr{ZZ

0 comments


#207 Rob Grijs / robgrijs - Score: 56 - 10/14/12 @ 16:00
f{r(f}r)A<BS>{<Esc>/(<CR>r[$i<BS>]<Esc>j0f{r($vhhc) {<Esc>j7lr(12lr)jr}jhr}ZZ

0 comments


#208 clint tseng / cxlt - Score: 57 - 12/28/10 @ 21:28
qaf}r)F{r($<Esc>qr{<Down><Right>r]F(r[<Down>@ar{<Down>@a<Down>r}<Down><Left>r}ZZ

0 comments


#209 Axl Waii / axlwaii - Score: 57 - 08/26/12 @ 12:58
/[][(){}]<CR>r(nr)nr{nr[nr]nr(nr)nr{nnnr(nnnr)nnnnr}nr}<Esc>:wq<CR>

0 comments


#210 Milind Ganjoo / mganjoo - Score: 57 - 01/25/14 @ 22:29
f{r(2Er)wr{4w%r]<C-O>r[jf}%r(<C-O>r)wr{jww%r}<C-O>wr<Esc>hr(4EEhr)jr}:wq<CR>

0 comments


#211 Brandon Ferguson / bnferguson - Score: 60 - 12/31/10 @ 22:26
f{r(f}r)f{f[r{2Gf(r[f)r]3g3G3Gf{r(f}r)f(r{jf{r(f}r)jr}jhr}ZZ

0 comments


#212 Matt York / yorkmatt - Score: 60 - 02/13/12 @ 18:54
f{r(f}r)f[r(r{jF(r[f)]<Esc>r]jF{r(f}r)llr{jf{r(f}r)jr}jhr}:w<CR>:q<CR>

0 comments


#213 Sean Wolfe / swolfe - Score: 62 - 12/28/10 @ 22:09
:%s/{\(.*\)}/(\1)<CR>`<Esc>1GA<BS>{<Esc><Down>5Br[$hr]<Down>r{<Down><Down>r}jhr}:x<CR>

0 comments


#214 wesrog / wesrog - Score: 62 - 12/28/10 @ 22:20
f{r(f}r)r<Esc>f[r{j0f(r[f)r]j0wwr(f}r)f(r{jf{r(f}r)jr}jhr}<Esc>:wq<CR>

0 comments


#215 Thibault Jouan / tjouan - Score: 62 - 12/29/10 @ 22:34
:%s/{\(.*\)}/(\1)/<CR>/[$<CR>r{/^]<CR>r}/(1<CR>r[/)<CR>r]/($<CR>r{/)$<CR>r}<CR>:wq<CR>

0 comments


#216 Suhas V / vhasus - Score: 63 - 04/15/13 @ 12:01
:%s/{/(/<CR>:<Up><Left><BS>)<Left><Left><BS>}<CR>:2,2s/(/[/<CR>:<Up><Left><BS>]<Left><Left><BS>)<CR>:e<BS>3<CR>$r{:5<CR>r}gg$r{Gr}ZZ

0 comments


#217 flembo's dad / Lspacewalker - Score: 65 - 12/19/11 @ 19:45
f1di}r)hr(p$r{/1<NL>di(r]hr[p/var<NL>di{r)hr(pf(r{/{<NL>ldi{r)hr(p+r}+r}ZZ

0 comments


#218 Global Maquereau / GlobalMaquereau - Score: 65 - 12/31/12 @ 10:54
:%s/{\(.*\)}/(\1)<CR>:2s/(\(.*\))/[\1]<CR>:1s/\[/{<CR>:6s/\]/}<CR>klr}2k$r{ZZ

0 comments


#219 Henri Bourcereau / mmai - Score: 66 - 12/30/10 @ 13:36
:%s/}/)<CR>:<Up><Left><Left><BS>{<Right><Right><BS>(<CR>/[<CR>r{n./(<CR>r[$hr]nr{un.*r[jr}jh.ZZ

0 comments


#220 Chris Parsons / chrismdp - Score: 67 - 12/28/10 @ 22:49
/{r(<BS><BS><CR>r(n.n./}<CR>r)n.n.f(r{jjr}:2<CR>f(r[f)r]kf{f[r{jjjjjhr}:wq<CR>

0 comments


#221 Jon Ferrer / jonnyheadphones - Score: 68 - 12/29/10 @ 22:11
f{r(2Er)2lf{fr{$r{Gr}3kf{r(f}r)wr{2jr}3kf(r[f)r]2jf{f}r)%f{r(:wq<CR>

0 comments


#222 Matthew Kirk / mjkirk - Score: 69 - 12/29/10 @ 00:19
:%s/{/\(/g<CR>:%s/}/\)/g<CR>gg$r{<Down><Right>r]18<Left>r[<Down>$r{2<Down>r}<Down><Left>r}:wq<CR>

0 comments


#223 Oliver Christ / 0liverChrist - Score: 69 - 09/30/13 @ 21:08
<Up><Up><Up><Up><Up><Up><Up><Up><Up><Up><Up><Up><Up><Up><Up>f{r(f}r)llr{jlr]F(r[jF{r(f}r)llr{jaf<Esc>uf{r(f}r)jr}+r}ZZ

0 comments


#224 Jonathan Perret / jonathanperret - Score: 72 - 12/28/10 @ 21:21
%%r(<C-O>r)$]]r}<C-O>r{j%%r]%<C-O>r<Left><Left><Left>5<Esc>llr{r[j%%r)<C-O>r($])r}<C-O>r{jf{%r)<C-O>r(:wq<CR>

0 comments


#225 Korbinian Stoemmer / PaulSmecker - Score: 72 - 03/08/13 @ 14:08
$r{Gr}<C-B>gg4wr(3wwr)jwwkWWllr[ww6w3wlr]jr{br)4bjkhr(j8whr(4w4wblr)jr}<Esc>:wq<CR>

0 comments


#226 Михаил Минков / _x10 - Score: 82 - 09/15/11 @ 14:42
:s/{/(<CR><Down><Down>:<Up><CR><Down>:<Up><CR>:<Up><BS><BS><BS>}/)<CR><Up>:<Up><CR><Up><Up>:<Up><CR><Down>:<Up><BS><BS><BS>[<BS>(/[/<BS><CR><End><Left>o<BS><BS><BS><BS>];<Down><BS>{<Down><Down><BS>}<Down><Left><BS>}<Up><Up><Up><Up><Up><End><BS>{<Esc><F2>:wq<CR>

0 comments


#227 Jeremy Johnstone / jsjohnst - Score: 83 - 12/29/10 @ 10:13
:g/./|s/{/(/|s/}/)/|s/\[$/{/|s/^]/}/|s/($/{/|s/)$/}/<CR>::2g/./|s/(/[/|s/)/]/<CR><CR>:wq<CR>

0 comments


#228 R / 7vies - Score: 84 - 07/18/11 @ 00:11
/{<CR>r(eeekklr)er{/(<CR>r[/)<CR>r[ur]/{r(<BS><BS><CR>r(<CR>ur(/}r)<BS><BS><CR>r)er{/{<CR>r(/}r<BS><CR>r)/)<CR>.nnr}ejjhr}:wq<CR>

0 comments


#229 David / ddddddddavid - Score: 107 - 12/30/10 @ 04:38
:.,<BS><BS>s/<BS><BS>%s//<BS>{/(/cg<CR>yyygg:<Up><Left><Left><Left><Left><Left><BS>}<Right><Right><BS>)<CR>yyykkf(r[f)r]jr{jjr}jhr}ggf[r{:wq<CR>

0 comments


#230 Zhao Yao / Lynch8080 - Score: 112 - 12/31/10 @ 17:38
f{r(f}r)f[r{jhhhhhhhhhhhhhhhhhr[r)r[<Esc>f)r]jf{f{^llllr(f}r)llr{jllllllllhr(f}r)jjhr}klr}<CR>;wq:w<Esc>:<Esc>q<CR>:q<CR>:eq<BS><BS>wq<CR>

0 comments


#231 neleai / enlaei - Score: 128 - 12/31/10 @ 22:04
:3s/(/{<CR>:6s/]/}<CR>:1s/{/(<CR>:<Up><Left><Left><BS>}<End><BS>)<CR>:<Up><Left><Left><BS>[<End><BS>{<CR>:<Up><Left><Left><Left>\<CR>:<Up><Home>2<Del><Right><Right><Del><Del>(<End><BS>[<CR>:<Up><Left><Left><BS>{<BS>)<End><BS>]<CR>:4s/{/)<BS>(<CR>:<Up><Left><Left><BS>}<End><BS>)<CR>:<Up><Left><Left><Left><Left><Left><BS>3<CR>:<Up><Up><Up><Home><Del>3<CR>:5s/)/}<CR><Esc>:wq<CR>

0 comments


#232 Ed Gibbs / edward_gibbs - Score: 188 - 08/15/11 @ 05:15
wwwwr(wwwwr)wr[wwwwr[wwwwwwwwwwww<Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Up><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right>r]wwr(wwwwww<Left><Left>r)wr{wwwwwww<Right>r(wwwwwww<Right>r)wwwwwwr}<Up><Up><Up><Up><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right>r{<Down><Down><Down><Down><Down><Down><Down><Down><Left>r}<Esc>:w<CR>:q<CR>

0 comments


Created by: sabiddle

232 active golfers, 617 entries

Leaderboard (lowest score wins):
34
#1 - Renat Aksitov / Korvin79

01/28/2012 at 05:02PM

34
#2 - Rod Knowlton / codelahoma

05/26/2012 at 08:49PM

34
#3 - Urtica dioica / udioica

06/09/2012 at 02:08AM

34
#4 - John Piasetzki / jpiasetz

07/13/2012 at 03:56AM

34
#5 - 刘玮 / lwjef

08/15/2012 at 12:34PM

34
#6 - Charles Gordon / liberalbias

08/24/2012 at 02:02AM

34
#7 - Conner McDaniel / connermcd

09/18/2012 at 05:09PM

34
#8 - Victor Ramirez / virako

10/01/2012 at 10:47AM

34
#9 - Vim rocks / vimrocks

10/06/2012 at 11:38AM

34
#10 - a24f0600 / a24f0600

12/14/2012 at 09:07AM

34
#11 - Averell Dalton / webtwoosucks

01/02/2013 at 10:22PM

34
#12 - Jimmy Mabey / mabeyj

01/20/2013 at 02:26AM

34
#13 - Yann Moisan / YannMoisan

02/01/2013 at 02:46PM

34
#14 - xavier kt / xav_kt

02/04/2013 at 08:14PM

34
#15 - Petro Тrouq / zulolosi

03/27/2013 at 12:26AM

34
#16 - Bradd Szonye / bszonye

07/14/2013 at 08:26AM

34
#17 - John Braxler / braxler

04/16/2014 at 08:07PM

34
#18 - kimber gonzalez / kimberlycreates

01/22/2015 at 02:51PM

34
#19 - pftb12345 / pftb12345

04/12/2015 at 01:32PM

34
#20 - Jon Krause / jkrause314

01/11/2016 at 09:56PM

34
#21 - Turkey Man / lvturkeyman

11/26/2017 at 07:37AM

35
#22 - Antony Scriven / antonyscriven

02/06/2011 at 12:35PM

35
#23 - Hu Junfeng / junfeng

07/15/2011 at 07:53AM

36
#24 - oliver mueller / marcontwit

01/22/2012 at 08:08AM

36
#25 - Sofia Balicka / so_phifi

03/20/2013 at 09:57AM

37
#26 - Ravil Bayramgalin / brainopia

01/02/2011 at 04:57PM

37
#27 - Wei Dai / clvv42

01/03/2011 at 02:04AM

37
#28 - Tim Dean / Tmdean

01/05/2011 at 07:16PM

37
#29 - Ruy Diaz / diazruy

03/11/2011 at 04:43AM

37
#30 - Terje Larsen / terlars

05/12/2011 at 11:46AM