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.
#105 davidnorth / @davidnorth - Score: 33 - 01/01/11 @ 19:07
:g/./m0<CR>qqI<C-R>=line('.')<CR>. <Esc>jq5@qZZ
0 comments
#106 Jens-Chr. Fischer / @jcfischer - Score: 33 - 01/03/11 @ 02:40
:g/./m0<CR>qqI<C-R>=line('.')<CR>. <Esc>jq5@qZZ
0 comments
#107 aaaa3331 / @aaaa3331 - Score: 33 - 01/03/11 @ 13:48
:%s!^!\=7-line(".").". "!|sort<CR>ZZ
0 comments
#108 David Duponchel / @dduponchel - Score: 33 - 01/08/11 @ 11:07
<C-V>GI6. <Esc>jr5jr4jr3jr2jr1Vgg:sort<CR>ZZ
0 comments
#109 Stephan Weller / @stephan_weller - Score: 33 - 01/10/11 @ 13:16
:g/./m0<CR>qqI<C-R>=line('.')<CR>. <Esc>jq5@qZZ
0 comments
#110 drio / @drio - Score: 33 - 01/11/11 @ 05:32
<C-V>GI6. <Esc>jr5jr4jr3jr2jr1Vgg:sort<CR>ZZ
0 comments
#111 Andrey A. Ugolnik / @andreyugolnik - Score: 33 - 01/19/11 @ 11:46
:%s!^!\=7-line(".").". "!|sort<CR>ZZ
@andreyugolnik: Not mine solution. Even more i can't understund how this works.
1 comment
#112 William Dunand / @wdunand - Score: 33 - 11/28/11 @ 00:34
:g/./m0<CR>:%s/^/\=line(".").". "<CR>ZZ
0 comments
#113 Al / @96258 - Score: 33 - 12/14/11 @ 08:31
:g/^/m0<NL>qqI<C-R>=line(".")<NL>. <Esc>jq5@qZZ
0 comments
#114 Xavier Nayrac / @lkdjiin - Score: 33 - 12/30/11 @ 07:46
:g/./m0<CR>qaI<C-R>=line('.')<CR>. <Esc>jq5@aZZ
0 comments
#115 akira_simpson / @akira_simpson - Score: 33 - 01/31/12 @ 10:18
<C-V>GI6. <Esc>jr5jr4jr3jr2jr1Vgg:sort<CR>ZZ
0 comments
#116 Dan Huang / @yuzeh - Score: 33 - 02/15/12 @ 16:10
<C-V>GI6. <Esc>jr5jr4jr3jr2jr1Vgg:sort<CR>ZZ
0 comments
#117 Tom Duijf / @tomduijf - Score: 34 - 02/12/11 @ 10: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
#118 Raul Brito / @raulbrito - Score: 34 - 06/16/11 @ 02:30
<C-V>GI6. <Esc>jr5jr4jr3jr2jr1<C-V>gg<End>:sort<CR>ZZ
0 comments
#119 Joe Hassick / @jhassick - Score: 36 - 12/31/10 @ 10:22
:g/^/m0<CR>i1. <Esc>qav^yjP^<C-A>q4@a<C-V>kkkA. <Esc>ZZ
0 comments
#120 Nicolas Friedli / @NicolasFriedli - Score: 36 - 10/28/12 @ 12:11
i6<Down><Left><Up><Esc>u<C-V>GI6. <Esc>jr5jr4jr3jr2jr1:sor<CR>ZZ
0 comments
#121 woodspock / @woodspock - Score: 37 - 12/31/10 @ 10:48
ddGpggdd<k4>jPggdd<k3>jpuPggddjpkddkPZZ
0 comments
#122 Solomon White / @rubysolo - Score: 38 - 01/02/11 @ 16:14
:%s/^/\=7-line(".")." <BS>. "/<CR>:%!sort<CR>ZZ
0 comments
#123 Joel Taylor / @otte_rs - Score: 39 - 12/31/10 @ 15:42
:g/^/m0<CR>:^<BS>%s/^/l<BS>\=line"<BS>(".").". "<CR>ZZ
0 comments
#124 Antoine Hérault / @Herzult - Score: 39 - 01/03/11 @ 14:14
<C-V>jjjjjjjjjI1. <Esc>r6jr5jr4jr3jr2:%sort<CR>:x<CR>
0 comments
#125 solsTiCe d'Hiver / @solstice_dhiver - Score: 40 - 01/01/11 @ 13:11
:sort! /.*/<CR><C-V><Down><Down><Down><Down><Down>I1. <Esc><Down>r2jr3jr4jr5jr6ZZ
0 comments
#126 Toto l'haricot / @nico_le_terribl - Score: 43 - 01/09/11 @ 10: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
#127 David E Smith / @david3smith - Score: 45 - 12/31/10 @ 11:28
:g/%/<BS><BS>^/m0<CR>:%s/^/\=line(.<BS>'.').'. '<CR>ZZ
0 comments
#128 Joshua Flanagan / @jflanagan - Score: 46 - 12/31/10 @ 16:01
:g/^/m0<CR>i1. <Esc>j^i2. <Esc>j^.^<C-A>j.i4. <Esc>j^.^<C-A>j.i6. <Esc>ZZ
0 comments
#129 libicocco / @libicocco - Score: 50 - 12/31/10 @ 11:08
:%s/^/1. <CR>Vkkdr4ggr6Pr3ddr2pjddggPjjjddr5pjdd4GPZZ
0 comments
VimGolf