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 52552abfb089a00002000007

Create Leading Zeros

Create leading zeros only for id columns. Please use generic approach!

Start file
id	data	age	parent_id
11	"Test"	12	123
123	"Test2	11	null
155	"Test5	19	123
111	"Test"	12	1123
1123	"Test2	11	11
1155	"Test5	19	1123
211	"Test"	12	123
2123	"Test2	11	11
2155	"Test5	19	123
2111	"Test"	12	1123
3123	"Test2	11	11
3155	"Test5	19	1123
1	"root"	9	null
End file
id	data	age	parent_id
0011	"Test"	12	0123
0123	"Test2	11	null
0155	"Test5	19	0123
0111	"Test"	12	1123
1123	"Test2	11	0011
1155	"Test5	19	1123
0211	"Test"	12	0123
2123	"Test2	11	0011
2155	"Test5	19	0123
2111	"Test"	12	1123
3123	"Test2	11	0011
3155	"Test5	19	1123
0001	"root"	9	null

View Diff

2,6c2,6
< 11	"Test"	12	123
< 123	"Test2	11	null
< 155	"Test5	19	123
< 111	"Test"	12	1123
< 1123	"Test2	11	11
---
> 0011	"Test"	12	0123
> 0123	"Test2	11	null
> 0155	"Test5	19	0123
> 0111	"Test"	12	1123
> 1123	"Test2	11	0011
8,10c8,10
< 211	"Test"	12	123
< 2123	"Test2	11	11
< 2155	"Test5	19	123
---
> 0211	"Test"	12	0123
> 2123	"Test2	11	0011
> 2155	"Test5	19	0123
12c12
< 3123	"Test2	11	11
---
> 3123	"Test2	11	0011
14c14
< 1	"root"	9	null
---
> 0001	"root"	9	null

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 56 remaining solutions by signing in and submitting your own entry
#57 Shaun Robinson / env - Score: 48 - 02/11/14 @ 03:31
ji0<Esc>.<Down>.j.j.3j.6j...WWWkk..2k.k..k.2k..2k.2k.<Esc><BS>ZZ

0 comments

#58 Bambu / bambumandinga - Score: 49 - 01/08/14 @ 06:32
:%s/\v^\d+|\d+$/\=printf('%.4d',submatch(0))/g<CR>ZZ

0 comments

#59 vim doof / vimdoof - Score: 49 - 09/23/14 @ 22:23
:%s/\v^\d+|\d+$/\=printf('%04d',submatch(0))/g<CR>ZZ

0 comments

#60 Lupus Woulfe / vim_mernd - Score: 49 - 09/23/14 @ 22:23
:%s/\v^\d+|\d+$/\=printf('%04d',submatch(0))/g<CR>ZZ

0 comments

#61 Zach Kemp / zvksf - Score: 50 - 12/17/13 @ 17:22
:%s;^\d\+\|\d\+$;\=printf('%04d',submatch(0));g<CR>ZZ

0 comments

#62 eirc / eirc - Score: 50 - 01/16/14 @ 15:51
<Down>i0<Esc>.<Down>.<Down>.<Down>.<Down><Down><Down>.<Down><Down><Down><Down><Down><Down>...5w<Up><Up>..<Up><Up>.<Up>..<Up>.<Up><Up>..<Up><Up>.<Up><Up>.ZZ

0 comments

#63 Franz Huber / bgmictf - Score: 57 - 10/11/13 @ 12:51
ji00<Down><Left><Left>0<Down><Left>0<Down><Left>0<Down><Down><Down><Left>0<Esc>G3i0<Esc>:%s/\t123/\t0123<CR>:%s/11$/0011<CR>ZZ

0 comments

#64 Timothée Gauthier / zmf_tim - Score: 58 - 11/13/14 @ 13:59
+qaciw0<Esc>pq@a$@@+@@+@@$@@+@@+$2@@++@@$@@<Down>2@a<Down>@@<Down><Down>2@a++3@aZZ

0 comments

#65 Pedro Santos / pedrosans - Score: 63 - 02/25/14 @ 20:40
w<C-V>G5wh"xx:%s/\v(^|\s)(\d{1,3})($|\s)/\10\2\3/g<CR>:%&<CR>:%&<CR>ggw"xPZZ

0 comments

#66 Travis Millott / ritherz - Score: 66 - 10/10/13 @ 19:48
hjui00<Esc><Down>bi0<Esc>hj.j.jjj.jjjjjj...kk$B..jkkkk..k.jj.kkkk..kk.kk.:w<CR>:q<CR>

0 comments

#67 Eric Potter / pottereric - Score: 66 - 10/24/13 @ 17:36
ji00<Esc>:%s/^\d\{3\}\t/0&<CR>Gi000<Esc>:%s/\t123$/\t0123<CR>:%s/\t11$/\t0011<CR>ZZ

0 comments

#68 Andreas Källberg / Anka213 - Score: 72 - 01/17/14 @ 05:57
jqqcw<C-R>=printf('%04d',@")<CR>b<BS><Esc>bjq14@qgg$jb14@<0xc5><0x82>14@qcwnull<Esc>3<Esc>10kkbcwnull<Esc>ZZ

0 comments

#69 John Moon / johnmoon6 - Score: 88 - 11/18/13 @ 14:01
ji00<Esc>jhi0<Esc>ji0<Esc>ji0<Esc>3ji0<Esc>7ji000<Esc>wwwww2ki00<Esc>2j4kbi0<Esc>ki00<Esc>ki<Left>9<Esc>r02ki00<Esc>2kh0eewwwi0<Esc>2ki0<Esc>:wq<CR>

0 comments

#70 RobertT / techrt2050 - Score: 127 - 10/10/13 @ 00:55
:v/null/s/\t\([0-9]\)$/\t000\1<CR>:<Up><Left><Left><BS><Left><Left><Left><Left><Left><Left><Left><Left>[0-9]<CR>:<Up><Left><Left><BS><Left><Left><Left><Left><Left><Left><Left>[0-9]<CR>:v/^id/s/^\(.\)\t/000\1\t<CR>:<Up><Left><Left><Left><Left><BS><Left><Left><Left><Left><Left><Left><Left>.<CR>:<Up><Left><Left><Left><Left><BS><Left><Left><Left><Left><Left><Left>.<CR>ZZ

0 comments

Created by: robrob12

70 active golfers, 178 entries

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

10/09/2013 at 07:53PM

23
#2 - Petro Тrouq / zulolosi

10/09/2013 at 11:50PM

23
#3 - Ingo / ist3fani

10/12/2013 at 09:28AM

23
#4 - Conner McDaniel / connermcd

10/30/2013 at 05:22AM

23
#5 - Yann Moisan / YannMoisan

01/02/2014 at 12:55AM

23
#6 - John Braxler / braxler

03/28/2014 at 09:31PM

23
#7 - Lifepillar / lifepillar

06/27/2015 at 02:36PM

24
#8 - Trevor Powell / DoomedBunnies

10/09/2013 at 11:27AM

24
#9 - Tim Chase / gumnos

10/09/2013 at 03:56PM

24
#10 - Jamie Schembri / shkm

10/09/2013 at 06:31PM

24
#11 - Sergio Benitez / Sergio965

10/09/2013 at 08:47PM

24
#12 - Sencer Selcuk / sencers_

10/10/2013 at 03:25AM

24
#13 - StarkHalo / hellektor

10/14/2013 at 12:47AM

24
#14 - Bradley M. Small / BradleySmall

10/23/2013 at 06:44PM

24
#15 - Tzipan / Tzipan

10/25/2013 at 11:59AM

24
#16 - James O Smith / josmith4242

10/26/2013 at 07:31PM

24
#17 - thasso / thasso23

10/27/2013 at 12:25PM

24
#18 - Nathan Wallace / nathanmwallace

11/05/2013 at 07:54PM

24
#19 - Shawn Dumas / shawndumas

11/06/2013 at 06:11AM

24
#20 - Jonathan Potter / nTypeRed

11/11/2013 at 07:19PM

24
#21 - ynwsoft / ynwsoft

12/20/2013 at 11:01AM

24
#22 - Joshua Appelman / JoshuaAppelman

12/21/2013 at 08:59PM

24
#23 - Ali El Amine / Allouch95

02/04/2014 at 09:58AM

24
#24 - Joonas Pihlajamaa / jokkebk

02/21/2014 at 10:38PM

24
#25 - pftb12345 / pftb12345

04/14/2015 at 01:08PM

26
#26 - Kai Yuan / kentyuan

10/09/2013 at 10:49AM

26
#27 - Tyler / tylerbindon

10/13/2013 at 06:13AM

26
#28 - buz / buzbone

10/15/2013 at 08:57AM

26
#29 - gary.klindt@googlema / garstekli

11/12/2013 at 06:59PM

26
#30 - Kerson Hsiao / KersonHsiao

08/31/2014 at 11:19AM

26
#31 - Matthieu Crapet / mcr05

01/10/2015 at 07:08PM

26
#32 - Walker Boh / walker_boh

12/07/2015 at 12:26PM

27
#33 - Adam McLain / adammclain

10/09/2013 at 04:54PM

28
#34 - codegourmet / codegourmet

10/09/2013 at 10:37AM

28
#35 - Marcin Sza / coot_

10/09/2013 at 04:01PM

28
#36 - evilmoe ☮ / evilmoe

10/13/2013 at 06:14PM

28
#37 - cj / cj01101

10/18/2013 at 10:15PM

29
#38 - Stefan Schmidt / stafue

12/06/2013 at 10:06AM

29
#39 - Gurukandhamoorthi / Gurukandhamoor1

08/20/2017 at 03:11PM

31
#40 - Édouard M'tou / DouardM

10/09/2013 at 06:37PM

31
#41 - aRkadeFR / aRkadeFR

10/10/2013 at 06:36AM

31
#42 - Ian Oxley / ianoxley

10/10/2013 at 12:10PM

31
#43 - James / Dronak

10/10/2013 at 02:02PM

32
#44 - Jacob Buete / JBuete

07/04/2017 at 06:56AM

43
#45 - Steve Tjoa / stevetjoa

10/11/2013 at 06:24PM

43
#46 - Devin V. / enrual

12/15/2013 at 06:01AM

43
#47 - Robert Argeanton / argeanton

01/06/2014 at 08:45AM

43
#48 - Quota / Quotad

01/20/2014 at 01:37PM

44
#49 - Oliver Christ / 0liverChrist

10/23/2013 at 09:47PM

44
#50 - Dmitry Petrov / can3p

02/25/2014 at 10:41AM

44
#51 - Patrick Pitoscia / Patrick03960431

08/20/2014 at 03:13AM

44
#52 - Ben Hill / KaizenSoze70

06/16/2016 at 06:24PM

46
#53 - Ram Tamtam / ramtamtamtam

06/30/2014 at 12:56PM

46
#54 - Justin Knag / justinknag

08/28/2014 at 04:28PM

47
#55 - Chris Ford / ctford

10/20/2013 at 08:05AM

47
#56 - Alex Bartol / alexbartol

05/13/2015 at 11:29PM

48
#57 - Shaun Robinson / env

02/11/2014 at 03:31AM

49
#58 - Bambu / bambumandinga

01/08/2014 at 06:32AM

49
#59 - vim doof / vimdoof

09/23/2014 at 10:23PM

49
#60 - Lupus Woulfe / vim_mernd

09/23/2014 at 10:23PM

50
#61 - Zach Kemp / zvksf

12/17/2013 at 05:22PM

50
#62 - eirc / eirc

01/16/2014 at 03:51PM

57
#63 - Franz Huber / bgmictf

10/11/2013 at 12:51PM

58
#64 - Timothée Gauthier / zmf_tim

11/13/2014 at 01:59PM

63
#65 - Pedro Santos / pedrosans

02/25/2014 at 08:40PM

66
#66 - Travis Millott / ritherz

10/10/2013 at 07:48PM

66
#67 - Eric Potter / pottereric

10/24/2013 at 05:36PM

72
#68 - Andreas Källberg / Anka213

01/17/2014 at 05:57AM

88
#69 - John Moon / johnmoon6

11/18/2013 at 02:01PM

127
#70 - RobertT / techrt2050

10/10/2013 at 12:55AM