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

CSV to JSON

A search for shortest vimissh way to convert CSV to JSON.

Start file
Year,Make,Model,Length
1997,Ford,E350,2.34
2000,Mercury,Cougar,2.38
End file
[
	{
		"Year": "1997",
		"Make": "Ford",
		"Model": "E350",
		"Length": "2.34"
	},
	{
		"Year": "2000",
		"Make": "Mercury",
		"Model": "Cougar",
		"Length": "2.38"
	}
]

View Diff

1,3c1,14
< Year,Make,Model,Length
< 1997,Ford,E350,2.34
< 2000,Mercury,Cougar,2.38
---
> [
> 	{
> 		"Year": "1997",
> 		"Make": "Ford",
> 		"Model": "E350",
> 		"Length": "2.34"
> 	},
> 	{
> 		"Year": "2000",
> 		"Make": "Mercury",
> 		"Model": "Cougar",
> 		"Length": "2.38"
> 	}
> ]

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 46 remaining solutions by signing in and submitting your own entry
#47 無ん垢の叫び / john_ababa - Score: 155 - 02/24/12 @ 08:10
YjpJkkJ:<C-P>%s/\(.*\),\(.*\),\(.*\),\(.*\) \(.*\),\(.*\),\(.*\),\(.*\)/[<C-V><CR><Tab>{<C-V><CR><Tab><Tab>"\1": "\5",<C-V><CR><Tab><Tab>"\2": "\6",<C-V><CR><Tab><Tab>\3<BS><BS>"\3": "\7",<C-V><CR><Tab><Tab>"\4": "\8"<C-V><CR><Tab>},<C-V><CR>]<CR>kllD7kdjZZ

0 comments

#48 Przemysław Pawełczyk / przemoc86 - Score: 156 - 01/15/11 @ 22:29
!Gawk -F, 'NR<2{for(;i++<NF;)h[i]=$i;print"["}NR>1{print"\t{";for(i=0;i++<NF;)print"\t\t\""h[i]"\": \""$i"\""(i<NF?",":"");print"\t},"}END{print"]"}'<CR>%k$xZZ

0 comments

#49 Franco Lazzarino / flazz - Score: 157 - 01/04/11 @ 20:19
:%s/,/<C-V><CR>/g<CR>:%norm I"<CR>:%norm A"<CR>:1,4norm A: <CR>:5,7norm A,<CR>:<Up><Left><Left><Left><Left><Left><Left><Left><BS><BS><BS>9,11<CR>:<Esc><Esc>gg<C-V>jjj$x5ggP9ggP:s<BS>%s/:\s*/: /<CR>8ggo},<CR>{<Esc>Go}<CR>]<Esc>5ggO{<Esc>O[<Esc>kdgg:2,13><CR>:3,6><CR>:9,12><CR>ZZ

0 comments

#50 Christopher Brew / Seph1rothVII - Score: 158 - 01/13/12 @ 18:51
i[<CR><Esc>Yjpjo]<Esc>:%s/\v^(\a+),(\a+),(\a+),(\a+)\n(\d+),(\a+),([^,]+),(w\<BS><BS>.+)$/\t{\r\t\t"\1": "\5",\r\t\t"\2": "\6",\r\t\t"\3": "\7",\r\t\t"\4": "\8"\r\t}/g<CR>7Ga,<Esc>ZZ

0 comments

#51 drio / drio - Score: 161 - 01/16/11 @ 15:48
:%s/,/<C-V><CR>/g<CR><C-V>ggI"<Esc>qqA": <Esc>0jq3@qqqA",<Esc>0jq7@q$D:8<CR>$Dgg"ayWj"byWj"cyWj"dyWj"aPj0"bPj0"cPj0"dPj0"aPj0"bPj0"cPj0"dPgg4ddO[<CR><Tab>{<Esc>j0v3j$>.:7<CR>O<Tab>},<CR>{<Esc>j0v3j$>.:12<CR>o<BS>}<CR>\<BS><BS>]<Esc>ZZ

0 comments

#52 Lajos Koszti / Ajnasz - Score: 166 - 01/06/11 @ 13:48
yyjpggqa:s/,/: /g<CR>df jPk^df jf,pk^df j2f,pk^Dj3f,pa: <Esc><Esc>^C{<CR><0xe2><0x87><0xa7>}<Esc>kkjo<Esc>pj^xk:s/,/,\r/g<CR>qjj@a:%s/\([a-z0-90<BS>.]\+\)/|\<BS><BS>:<BS>"\1"/g<CR>ggi[<Esc>Go]<Esc>kVjh%j>jVk%k>jj/{<CR>j.kkddka,<Esc><Esc>:x<CR>

0 comments

#53 Adrian Silva / scyldinga - Score: 176 - 01/10/12 @ 10:29
i[<CR><Tab>{<CR><Tab>"<Esc>wwi": "1997"<Esc>lli<CR>"<Esc>ww"i:<Esc><Esc>i": "Ford",<Esc>lxi<CR>"<Esc>wwi": "E35[<BS>0"<Esc>lli<CR>"<Esc>wwb$a": "3<BS>2.34"<CR>}<Esc><<o}<BS>]<Esc><<<Esc>:2,7y<CR>kpka,<Esc>jjf1ct"2000<Esc>jxcTF<Esc>xiMecr<BS><BS>rcury<Esc>jhcT"Cougar<Esc>jcT"2.38<Esc>3j2dd:x<CR>

0 comments

#54 Christopher Sexton / fuzzymonk - Score: 204 - 01/01/11 @ 20:08
:<Up>%s/\(\w\+\)/"\1"/g<CR>qq0f.dhlxq:2<CR>@qk0df,jPr:a <Esc>j0.uhPr: i <Esc>ggdf,jf,a<CR>P<BS><Esc>Pr:<Esc>jf,a<CR><Esc>Pr: i <Esc>ggdf,2j2f,F,a<CR><Esc>Pr:a <Esc>jjf,a<CR><Esc>Pr:a <Esc>ggDi[<CR><Tab>{<Esc>:5<CR>f,a<CR><Esc>Pa: <Esc>o},<CR>{<Esc>:11<CR>f,a<CR><Esc>Pa: <Esc>o}<CR>]<Esc>Vgg=j<C-V>jI<Tab><Esc>:7<CR><C-V>jjjjjjI<Tab><Esc>:4<CR>f:a <Esc>ZZ

0 comments

#55 Ilya Ermolin / ermolinis - Score: 210 - 01/01/11 @ 19:25
:let l = map(getline(1,3),'split(v:val,",")')<CR>:for i in range(4)<CR>let t = 1<CR>let l[t][i] = "\t\t\"".l[o]<BS><BS>0][i].'": '<BS>"'.l[t][i].'",'<CR><Up><Up><BS>2<CR><Up><Up><CR>endfor<CR>3dd:s/^/\=l[1]+l[2]<CR>gg0i<CR><Up>i<BS>[<CR><Tab>{<CR><Del><Tab><Down><Down><Down><Down><Up><End><Left><CR><BS>}<Right><CR>{<Down><Down><Down><Down><End><BS><CR><BS>}<CR><BS>]<Esc>ZZ

0 comments

#56 Mitch LeBlanc / symmitchry - Score: 231 - 10/22/14 @ 05:20
Yjp%s<Esc>u:%s/,/<C-V><CR>/g<CR>@sqadd3kpkJGq3@a4k4@aukjjjjqbdd4kpkJ3jq3@b:%s/norm ^i"<C-V><Esc>ea":<C-V>`<CR><Esc>:%s nr<BS>orm<Esc><Esc>:V<Esc><Esc>VGgg<Esc><Esc>VG:norm I"<C-V><Esc>ea": "<C-V><Esc>wx<C-V><Esc>A",<CR>kjhhhhhi2k<BS><Esc>lxkhhrCkhrMkr2kllr2khrFkhrFjlrRrEkkhr1I[<CR><Tab>{<CR><Tab><Esc>jVjj>.<Esc>jjA<BS><CR><BS>}<CR>,<BS><BS><BS>,<CR>{<Esc>jVG>.<Esc>G$xo<BS>}<CR><BS>]<Esc>ZZ

0 comments

#57 Dan Williams / deft_of_center - Score: 272 - 04/03/13 @ 04:02
:%s/^\|$/"/g<CR>:%s/,/",#"/g<CR>:s$<BS>/$/\r\t}\r]/<CR>:s,1<BS><BS><BS>,1s/^/[\r\t{\r/<CR>n<CR><Up><Up><Up><Up>:s/^/[\r\t{\r/<CR>:s/,/: /g<CR>A:<Esc>:%s/#/\r<CR>:<Up>/g<CR>qauuY<Down>p:%s/#/\r/g<CR>qadd<BS><BS><Esc>dd3kPkJjjjqa^DDdduuqqadd3j3k3kqjjjudd3kOuu<BS><BS><BS><Esc>uuuuuqadd3kPkJ3jq3@a4k4@a:s/&<BS>$/\r\t}.\<BS><BS>,\r{\r/<CR><Left><Down><Up><Up><Tab><Down><Up>i<Tab><Down><BS>:%s^<BS><BS><BS><BS><Esc>:s<BS>%s/^"/\t\t"/<CR>ZZ

0 comments

#58 ise0615 / ise0615 - Score: 395 - 05/13/12 @ 07:35
i"<Esc>wwi"<Right><CR>"<Esc>ww.ui"<Right><CR><Esc>.ui"<Esc>wwi"<Right><CR><Esc>.ui"<Esc>wwkwwblllllla"<CR><Esc>jkkkkkkkk$a<BS>:<Down><BS>:<Down><Right><BS>:<Down><Right>:<Esc>jkkkkkk0i[<CR>{<CR><Esc>jjjji},<CR><Esc>kkkkkkvjjjjjlljkhhyjjjjjpi,<CR><Esc>jjjjjlxji]<Esc>jv$dkkkkkkkkkkkk$pi <Esc>wwlv$djla <Esc>plllllv$djla <Esc>pllllv<Esc>lDjja<Esc>phhhi <Esc>kddjjjjjjjjjjjddkkkkk$pi<BS> <Esc>llllllDjla <Esc>pbbbbbv$duv$hdjla <Esc>pbhbv$duv$hdjla <Esc>pa"<Esc>hhhh.ub.u<Left><Left>.<Up><Left><Left>.<Up><Left><Left>.<Up><Left>.<Right><Right><Right><Right>.<Down><Right><Right>.<Down><Left>.<Up><Up><Up><Up><Up>.<Up><Left>.<Up><Left>.<Up><Left>.<Left><Left><Left><Left><Left>.<Down><Left>.<Down><Left><Right>.<Down><Right><Left>.<Esc>0kkkk<C-V>jjjjj>jl<C-V>jjjjk>jjjjj<C-V>jjjjj>jl<C-V>jjj>ZZ

0 comments

Created by: Ujjwol

58 active golfers, 141 entries

Leaderboard (lowest score wins):
56
#1 - Conner McDaniel / connermcd

09/25/2012 at 12:38AM

56
#2 - Urtica dioica / udioica

01/02/2013 at 05:42PM

56
#3 - John Braxler / braxler

08/25/2014 at 05:55PM

60
#4 - Douglas Stockwell / dstockwell

01/02/2011 at 12:21AM

60
#5 - Wei Dai / clvv42

01/02/2011 at 12:36AM

60
#6 - You-Siang Lin / yslinnctu

12/07/2011 at 12:35PM

60
#7 - Benjamin Sullivan / benjaminsull

12/11/2011 at 01:09PM

63
#8 - Jon Krause / jkrause314

02/16/2016 at 12:47AM

68
#9 - Justin Love / wondible

08/08/2011 at 03:38PM

75
#10 - Casey Dwyer / caseydwyer

10/23/2013 at 02:42PM

76
#11 - Tim Chase / gumnos

01/01/2011 at 01:06PM

76
#12 - Drew Neil / nelstrom

01/02/2011 at 01:42PM

76
#13 - François Marais / maraisf

10/15/2014 at 04:48PM

77
#14 - Hu Junfeng / junfeng

07/26/2011 at 09:00AM

79
#15 - Dragan Cvetinovic / kawkafi

05/22/2011 at 02:00PM

81
#16 - William Dunand / wdunand

11/21/2011 at 08:41AM

83
#17 - Nándor Komzák / rubymood

01/02/2011 at 10:10PM

84
#18 - not so punk :] / notsopunk

06/19/2011 at 04:12PM

85
#19 - rabidpraxis / rabidpraxis

01/02/2011 at 10:20PM

88
#20 - h_east (トロッコ6個) / h_east

01/01/2011 at 09:51AM

88
#21 - Naomi Chu / NaomiChuChunks

05/08/2014 at 07:06PM

89
#22 - Oliver Christ / 0liverChrist

11/12/2013 at 10:11PM

93
#23 - Karel Vervaeke / karel1980

01/03/2011 at 10:20AM

93
#24 - Glenn / spamcow_moo

01/03/2011 at 11:35PM

94
#25 - Austin Taylor / austintaylor

01/02/2011 at 04:18AM

97
#26 - Clément Nodet / clementnodet

01/03/2011 at 10:09PM

97
#27 - Akira Matsuda / a_matsuda

01/05/2011 at 03:46PM

100
#28 - Marian Schubert / MarianSchubert

01/01/2011 at 11:03PM

101
#29 - Pete Johns / johnsyweb

01/10/2011 at 05:59PM

104
#30 - Aurélien Delahaye / alkove

01/01/2011 at 03:52PM

105
#31 - Matti Hänninen / mjhanninen

01/30/2011 at 02:32PM

106
#32 - Asmund Liseth / Asmund_L

01/01/2011 at 08:32PM

107
#33 - Aaron Miller / apage43

08/13/2012 at 02:11AM

112
#34 - Ben Buckley / _benb

09/13/2013 at 07:34PM

114
#35 - Øystein Walle / oysteinwalle

07/06/2011 at 09:24AM

115
#36 - Clive Evans / swish_bob

01/01/2011 at 10:49PM

116
#37 - Behnam Esfahbod / zwnj

01/01/2011 at 02:57PM

120
#38 - Christoph Stock / christophstock

01/01/2011 at 04:15PM

121
#39 -  Ikhsan Maulana / ixandidu

01/15/2011 at 09:02AM

127
#40 - Renat Aksitov / Korvin79

02/06/2012 at 07:19PM

129
#41 - Francisco Dibar / frandibar

01/12/2011 at 10:28PM

131
#42 - George GZ Zakhour / AlloGeorge

10/01/2013 at 12:40PM

145
#43 - Rob Ciaccio / RobertoCalavera

02/01/2011 at 05:28PM

150
#44 - Alain Gilbert / alain_gilbert

01/01/2011 at 08:44PM

152
#45 - davidnorth / davidnorth

01/02/2011 at 12:51AM

153
#46 - Justin Cullen / zenguine

02/29/2012 at 06:34AM

155
#47 - 無ん垢の叫び / john_ababa

02/24/2012 at 08:10AM

156
#48 - Przemysław Pawełczyk / przemoc86

01/15/2011 at 10:29PM

157
#49 - Franco Lazzarino / flazz

01/04/2011 at 08:19PM

158
#50 - Christopher Brew / Seph1rothVII

01/13/2012 at 06:51PM

161
#51 - drio / drio

01/16/2011 at 03:48PM

166
#52 - Lajos Koszti / Ajnasz

01/06/2011 at 01:48PM

176
#53 - Adrian Silva / scyldinga

01/10/2012 at 10:29AM

204
#54 - Christopher Sexton / fuzzymonk

01/01/2011 at 08:08PM

210
#55 - Ilya Ermolin / ermolinis

01/01/2011 at 07:25PM

231
#56 - Mitch LeBlanc / symmitchry

10/22/2014 at 05:20AM

272
#57 - Dan Williams / deft_of_center

04/03/2013 at 04:02AM

395
#58 - ise0615 / ise0615

05/13/2012 at 07:35AM