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

Reverse and count

Someone typed things upside down and now a Vim ninja needs to reverse the lines and count how many there are.

Start file
Sixth line
Fifth line
Fourth line
Third line
Second line
First line
End file
1. First line
2. Second line
3. Third line
4. Fourth line
5. Fifth line
6. Sixth line

View Diff

1,6c1,6
< Sixth line
< Fifth line
< Fourth line
< Third line
< Second line
< First line
---
> 1. First line
> 2. Second line
> 3. Third line
> 4. Fourth line
> 5. Fifth line
> 6. Sixth line

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 115 remaining solutions by signing in and submitting your own entry
#116 aaaa3331 / aaaa3331 - Score: 33 - 01/03/11 @ 21:48
:%s!^!\=7-line(".").". "!|sort<CR>ZZ

0 comments


#117 David Duponchel / dduponchel - Score: 33 - 01/08/11 @ 19:07
<C-V>GI6. <Esc>jr5jr4jr3jr2jr1Vgg:sort<CR>ZZ

0 comments


#118 Stephan Weller / stephan_weller - Score: 33 - 01/10/11 @ 21:16
:g/./m0<CR>qqI<C-R>=line('.')<CR>. <Esc>jq5@qZZ

0 comments


#119 drio / drio - Score: 33 - 01/11/11 @ 13:32
<C-V>GI6. <Esc>jr5jr4jr3jr2jr1Vgg:sort<CR>ZZ

0 comments


#120 Andrey A. Ugolnik / andreyugolnik - Score: 33 - 01/19/11 @ 19:46
:%s!^!\=7-line(".").". "!|sort<CR>ZZ

andreyugolnik: Not mine solution. Even more i can't understund how this works.

1 comment


#121 William Dunand / wdunand - Score: 33 - 11/28/11 @ 08:34
:g/./m0<CR>:%s/^/\=line(".").". "<CR>ZZ

0 comments


#122 You-Siang Lin / yslinnctu - Score: 33 - 12/02/11 @ 11:39
<C-V>GI6. <Esc>jr5jr4jr3jr2jr1Vgg:sort<CR>ZZ

0 comments


#123 Al / 96258 - Score: 33 - 12/14/11 @ 16:31
:g/^/m0<NL>qqI<C-R>=line(".")<NL>. <Esc>jq5@qZZ

0 comments


#124 Xavier Nayrac / lkdjiin - Score: 33 - 12/30/11 @ 15:46
:g/./m0<CR>qaI<C-R>=line('.')<CR>. <Esc>jq5@aZZ

0 comments


#125 akira_simpson / akira_simpson - Score: 33 - 01/31/12 @ 18:18
<C-V>GI6. <Esc>jr5jr4jr3jr2jr1Vgg:sort<CR>ZZ

0 comments


#126 Dan Huang / yuzeh - Score: 33 - 02/16/12 @ 00:10
<C-V>GI6. <Esc>jr5jr4jr3jr2jr1Vgg:sort<CR>ZZ

0 comments


#127 Melvin Cheung / MelvinCheung - Score: 33 - 05/24/17 @ 15:50
:%s!^!\=7-line(".").". "!|sort<CR>ZZ

0 comments


#128 Tom Duijf / tomduijf - Score: 34 - 02/12/11 @ 18:02
<C-V>GI6. <Esc><Down>R5<Down><Left>4<Down><Left>3<Down><Left>2<Down><Left>1<Esc>Vgg:sort<CR>ZZ

0 comments


#129 Raul Brito / raulbrito - Score: 34 - 06/16/11 @ 09:30
<C-V>GI6. <Esc>jr5jr4jr3jr2jr1<C-V>gg<End>:sort<CR>ZZ

0 comments


#130  Ikhsan Maulana / ixandidu - Score: 35 - 12/31/10 @ 16:46
:g/^/m0<CR><C-V>GI. <Esc>:%s/^/\=line('.')<CR><C-Z>ZZ

0 comments


#131 yamasita taisuke / yaasita - Score: 35 - 07/12/14 @ 05:07
<C-V>GI1. <Esc>:5<CR>qajylk"_xP<C-A>kq4@a:%sort<CR>ZZ

0 comments


#132 Joe Hassick / jhassick - Score: 36 - 12/31/10 @ 18:22
:g/^/m0<CR>i1. <Esc>qav^yjP^<C-A>q4@a<C-V>kkkA. <Esc>ZZ

0 comments


#133 Nicolas Friedli / NicolasFriedli - Score: 36 - 10/28/12 @ 19:11
i6<Down><Left><Up><Esc>u<C-V>GI6. <Esc>jr5jr4jr3jr2jr1:sor<CR>ZZ

0 comments


#134 woodspock / woodspock - Score: 37 - 12/31/10 @ 18:48
ddGpggdd<k4>jPggdd<k3>jpuPggddjpkddkPZZ

0 comments


#135 Joel Taylor / joelteon_ - Score: 39 - 12/31/10 @ 23:42
:g/^/m0<CR>:^<BS>%s/^/l<BS>\=line"<BS>(".").". "<CR>ZZ

0 comments


#136 Antoine Hérault / Herzult - Score: 39 - 01/03/11 @ 22:14
<C-V>jjjjjjjjjI1. <Esc>r6jr5jr4jr3jr2:%sort<CR>:x<CR>

0 comments


#137 solsTiCe d'Hiver / solstice_dhiver - Score: 40 - 01/01/11 @ 21:11
:sort! /.*/<CR><C-V><Down><Down><Down><Down><Down>I1. <Esc><Down>r2jr3jr4jr5jr6ZZ

0 comments


#138 Toto l'haricot / nico_le_terribl - Score: 43 - 01/09/11 @ 18:58
I6. <Esc><Down>.<Down>.<Down>.<Up><Down><Down>.<Down>.05<C-X><Up>4<C-X><Up>3<C-X><Up>2.<Up>.r5:sor nu|x<CR>

0 comments


#139 David E Smith / david3smith - Score: 45 - 12/31/10 @ 19:28
:g/%/<BS><BS>^/m0<CR>:%s/^/\=line(.<BS>'.').'. '<CR>ZZ

0 comments


#140 Joshua Flanagan / jflanagan - Score: 46 - 01/01/11 @ 00:01
:g/^/m0<CR>i1. <Esc>j^i2. <Esc>j^.^<C-A>j.i4. <Esc>j^.^<C-A>j.i6. <Esc>ZZ

0 comments


#141 libicocco / libicocco - Score: 50 - 12/31/10 @ 19:08
:%s/^/1. <CR>Vkkdr4ggr6Pr3ddr2pjddggPjjjddr5pjdd4GPZZ

0 comments


#142 Jan B. / bracki - Score: 55 - 01/03/11 @ 16:52
:g/./m0<CR><C-V><Down><Down><Down><Down><Down><Down><Down><Down><Down><Down><Down><Down><Down><Down><Down><Down><Down>I1. <Esc>j<C-A>j<C-A><C-A>j<C-A><C-A><C-A>j<C-A><C-A><C-A><C-A>j<C-A><C-A><C-A><C-A><C-A><Esc>:x<CR>

0 comments


#143 Oliver Christ / 0liverChrist - Score: 57 - 10/16/13 @ 21:36
ddGpkddggPjddjjpkddkkPjddp:%s/^/\=line"(<BS><BS>(".").",<BS>. "<CR>ZZ

0 comments


#144 neleai / enlaei - Score: 78 - 12/31/10 @ 21:49
dd<Down><Down><Down><Down>p<Up>dd<Up><Up><Up><Up>pdd<Home><Up>p<Up>dd<Down><Down><Down>p<Up>dd<Up><Up><Up>p<Down>ddp<Up><Up><Up><Up>i1. <Down><Home>2. <Down><Home>3. <Down><Home>4. <Down><Home>5.,<BS> <Down><Home>6. <Esc>:wq<CR>

0 comments


Created by: jamesconroyfinn

144 active golfers, 377 entries

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

06/25/2015 at 07:17PM

18
#2 - Jon Krause / jkrause314

01/20/2016 at 10:29PM

18
#3 - Peter Brynza / v3_1

08/28/2016 at 08:07PM

18
#4 - Turkey Man / lvturkeyman

11/28/2017 at 06:20PM

18
#5 - DHM / DHM29978992

05/27/2018 at 01:48AM

21
#6 - Gurukandhamoorthi / Gurukandhamoor1

08/13/2017 at 04:05PM

22
#7 - Aurélien Delahaye / alkove

01/02/2011 at 09:29PM

22
#8 - Benoît Ryder / benoitryder

01/03/2011 at 10:48PM

22
#9 - Danny O'Sullivan / db0s

01/05/2011 at 11:01AM

22
#10 - Balkoth / _Balkoth_

01/08/2011 at 11:04PM

22
#11 - Tim Chase / gumnos

06/11/2011 at 12:27AM

22
#12 - not so punk :] / notsopunk

06/19/2011 at 05:21PM

22
#13 - Justin Love / wondible

07/19/2011 at 02:42PM

22
#14 - p0ckets / p0ckets

10/09/2011 at 07:58PM

22
#15 - Jaime A. Sánchez / jashbeta

12/22/2011 at 04:18AM

22
#16 - Vasil Sakarov / vsakarov

01/17/2012 at 06:40PM

22
#17 - Renat Aksitov / Korvin79

03/03/2012 at 06:25PM

22
#18 - Garry Shutler / gshutler

03/31/2012 at 06:11PM

22
#19 - Nolen Royalty / NolenRoyalty

04/22/2012 at 03:07AM

22
#20 - Conner McDaniel / connermcd

09/25/2012 at 12:04AM

22
#21 - Petro Тrouq / zulolosi

07/25/2013 at 03:21AM

22
#22 - John Braxler / braxler

05/18/2014 at 05:50PM

22
#23 - Evan Coleman / edc1591

06/01/2015 at 09:03PM

23
#24 - Thedward the Edward / thedward

12/31/2010 at 08:37PM

23
#25 - Wei Dai / clvv42

01/01/2011 at 01:18AM

24
#26 - Utkarsh Kukreti / utkarshkukreti

12/31/2010 at 05:06PM

24
#27 - Prody / Prody225

12/31/2010 at 05:22PM

24
#28 - Eike Schulte / eikeschulte

12/31/2010 at 05:32PM

24
#29 - Peter Anselmo / peter_anselmo

12/31/2010 at 07:28PM

24
#30 - Henri Bourcereau / mmai

12/31/2010 at 09:07PM