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

82 active golfers, 241 entries

Leaderboard (lowest score wins):
44
#61 - Ben Hill / @KaizenSoze70

06/16/2016 at 06:24PM

46
#62 - Ram Tamtam / @ramtamtamtam

06/30/2014 at 12:56PM

46
#63 - Justin Knag / @justinknag

08/28/2014 at 04:28PM

47
#64 - Chris Ford / @ctford

10/20/2013 at 08:05AM

47
#65 - Alex Bartol / @alexbartol

05/13/2015 at 11:29PM

48
#66 - Shaun Robinson / @env

02/11/2014 at 03:31AM

49
#67 - Bambu / @bambumandinga

01/08/2014 at 06:32AM

49
#68 - vim doof / @vimdoof

09/23/2014 at 10:23PM

49
#69 - Lupus Woulfe / @vim_mernd

09/23/2014 at 10:23PM

49
#70 - Pablo Acuna / @pacuna

11/02/2024 at 09:49PM

50
#71 - Zach Kemp / @zvksf

12/17/2013 at 05:22PM

50
#72 - eirc / @eirc

01/16/2014 at 03:51PM

57
#73 - Franz Huber / @bgmictf

10/11/2013 at 12:51PM

58
#74 - zmf_tim / @zmf_tim

11/13/2014 at 01:59PM

63
#75 - Pedro Santos / @pedrosans

02/25/2014 at 08:40PM

63
#76 - Simon Ingelsson / @_DeVVaN_

08/17/2018 at 07:31AM

66
#77 - Travis Millott / @ritherz

10/10/2013 at 07:48PM

66
#78 - Eric Potter / @pottereric

10/24/2013 at 05:36PM

72
#79 - Andreas Källberg / @Anka213

01/17/2014 at 05:57AM

74
#80 - Borna Sadeghi / @borna_sadeghi

03/19/2021 at 05:14AM

88
#81 - John Moon / @johnmoon6

11/18/2013 at 02:01PM

127
#82 - RobertT / @techrt2050

10/10/2013 at 12:55AM