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

Indentation

Indent each line according to the right number of spaces it needs.

Start file
this line doesn’t have indentation
this line is indented with two spaces
this one has four
this other one has two
this one is indented with two spaces
this line has a four spaces indentation
this line needs six spaces
this line needs six spaces too
this line is back to four spaces
this line is finally indented with two spaces
this final line is not indented
End file
this line doesn’t have indentation
  this line is indented with two spaces
    this one has four
  this other one has two
  this one is indented with two spaces
    this line has a four spaces indentation
      this line needs six spaces
      this line needs six spaces too
    this line is back to four spaces
  this line is finally indented with two spaces
this final line is not indented

View Diff

2,10c2,10
< this line is indented with two spaces
< this one has four
< this other one has two
< this one is indented with two spaces
< this line has a four spaces indentation
< this line needs six spaces
< this line needs six spaces too
< this line is back to four spaces
< this line is finally indented with two spaces
---
>   this line is indented with two spaces
>     this one has four
>   this other one has two
>   this one is indented with two spaces
>     this line has a four spaces indentation
>       this line needs six spaces
>       this line needs six spaces too
>     this line is back to four spaces
>   this line is finally indented with two spaces

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 111 remaining solutions by signing in and submitting your own entry
#112 aimee / sermoa - Score: 33 - 01/09/11 @ 16:03
j9>>:g/u/><CR>:g/x/>><CR>:%s/\t/  /g<CR>ZZ

sermoa: Go down to the second line and indent 9 lines. Look for everything with 'u' which matches 'four' and further indent those lines. Look for everything with 'x' which matches 'six' and indent those two more times. Finally replace all tabs with two spaces.

sermoa: I really like my solution because it's the first time i've used the :g command. I see that you can be less clever and achieve fewer keystrokes, but i'm more interested in learning something new than achieving the highest score.

rpattabi: u, x stuff is nice

3 comments

#113 eholic / eholic - Score: 33 - 04/04/11 @ 12:30
j<C-V>8jI  <Esc>ji  <Esc>3j<C-V>3jI  <Esc>j<C-V>jI  <Esc>:wq<CR>

0 comments

#114 Charlie Tanksley / charlietanksley - Score: 33 - 10/13/11 @ 16:13
j<C-V>8jI  <Esc>ji  <Esc>3j<C-V>3jA  <Esc>j<C-V>jI  <Esc>:wq<CR>

0 comments

#115 Stefan Schmidt / stafue - Score: 33 - 12/06/13 @ 16:42
jqqi  <Esc>+q8@q3gg@@2j@@2@q2k2@q@@ZZ

0 comments

#116 Jordi Romero / jordiromero - Score: 34 - 12/31/10 @ 15:59
jI  <Esc>j..j.j.j..j...j...j..j.:w<CR>:q<CR>

0 comments

#117 Stefan Mai / iamnafets - Score: 34 - 09/16/11 @ 07:44
:set sw=2<CR><Down>V8<Down>><Down>>><Down><Down><Down>V3<Down>><Down>V<Down>><Esc>:wq<CR>

0 comments

#118 Amir Hedayaty / hedayaty - Score: 35 - 12/30/10 @ 12:14
:set et<CR>:g/w/><CR>:g/u/>><CR>:g/x/>>><CR>:x<CR>

0 comments

#119 Bob Corsaro / doki_pen - Score: 35 - 12/30/10 @ 17:11
:se et<CR>j>>j..j.j.j..j...j...j..j.ZZ

0 comments

#120 Nicolas Friedli / NicolasFriedli - Score: 37 - 10/28/12 @ 19:17
<Down>I2<BS>  <Esc><Down><Left>..<Left><Down>.<Down>.<Down>..<Down>...<Down>...<Down>..<Down>.<Esc>:wq<CR>

0 comments

#121 Ben Brown / benofbrown - Score: 38 - 12/30/10 @ 19:09
ji  <Esc>j^..j^.j^.j^..j^...j^...j^..j^.ZZ

0 comments

#122 Heron Medeiros / heronmedeiros - Score: 39 - 04/13/14 @ 02:56
j<C-V>9<CR>kI  <Esc>vlyjp:6<CR>P:7<CR><C-V>jI    <Esc><Esc>:9<CR>P<Esc>:wq<CR>

0 comments

#123 Will Hardy / whrde - Score: 40 - 12/30/10 @ 15:07
j2I <Esc>2j.j.5j./x<CR>6I <Esc>j./ou<CR>4I <Esc>3k.3k.:wq<CR>

0 comments

#124 Avinash Baliga / avinashbaliga - Score: 40 - 03/24/11 @ 23:59
jqq0i  <Esc>qj2@qj@qj@qj2@qj3@qj3@qj2@qj@qZZ

0 comments

#125 Cássio Marques / cassiomarques - Score: 41 - 12/30/10 @ 11:50
j<C-V>8jc  t<Esc>j<C-V>6jc  t<Esc>:7<CR><C-V>jc  t<Esc>:4<CR>h<C-V>hjx<Esc>:wq<CR>

0 comments

#126 Lee Marlow / lmarlow - Score: 42 - 01/01/11 @ 05:48
j<C-V>jjjjjjjjI  <Esc>ji  <Esc>3ji  <Esc>j<C-V>jI    <Esc>2ji  <Esc>ZZ

0 comments

#127 Ben Lenarts / benlenarts - Score: 44 - 01/03/11 @ 22:59
:%g/tw/><CR>:%g/fo/>><CR>:%g/si/>>><CR>:%s/\t/  /g<CR>ZZ

0 comments

#128 Dave / zzdave13 - Score: 44 - 07/31/11 @ 09:16
:g/w/s/^/  <NL>:g/u/s/^/    <NL>:g/x/s/^/      <NL>ZZ

0 comments

#129 Shaun Robinson / env - Score: 45 - 02/11/14 @ 03:36
j<C-V>8jI  <Esc>ji  <Esc>3j<C-V>3j1I  <Esc>j<C-V>jI  <Esc>:w2<BS><BS>qw!<BS><BS><BS>wq!<CR>

0 comments

#130 Cyril Pascal / paxal - Score: 50 - 12/30/10 @ 17:57
:2,10s@^@  <CR><Left><C-V><Up><Left>y<Up>P<Up>P<Up>P<Up><Up><Up>i  <Esc>ZZ

0 comments

#131 Ragunathan Pattabi / rpattabi - Score: 52 - 05/10/11 @ 08:40
:g/w/><NL>:g/u/>><NL>:g/x/>>><NL>:%s!\t!  <NL>u:<Up>/g<NL>:<Esc>u:<Up><Left><Left><Del>!<NL>ZZ

0 comments

#132 solsTiCe d'Hiver / solstice_dhiver - Score: 56 - 01/07/14 @ 17:57
:g/two/s/^/  /<CR>:g/four/s/^/    /<CR>:g/six/s/^/      /<CR>:wq<CR>

0 comments

#133 alex scott / 4l3xsc0tt - Score: 60 - 12/30/10 @ 01:42
:<Up>2,10s/^/  <CR>:3s/^/  <CR>:6,0<BS>9s/^/  <CR>:7,8s^<BS>/^/  <CR>:x<CR>

0 comments

#134 Dylan Beattie / dylanbeattie - Score: 60 - 12/30/10 @ 15:03
:%s/.*tw/  &/|%<BS>%s/.*ix/      &/|%s/.*fo/    &/<C->|q<BS>wq<NL>

0 comments

#135 KMNK / kmnk - Score: 69 - 04/24/11 @ 07:39
js2 <Esc>ui  <Esc>jhhi    <Esc>jhhhhhi  <Esc>jI  <Esc>jI    <Esc>jI      <Esc>j.jI    <Esc>jI  <Esc>;:wq<CR>

0 comments

#136 Amit Kulkarni / amitkkulkarni - Score: 92 - 12/30/10 @ 07:30
i<Down>  <Down><Home>    <Down><Home>  <Down><Home>  <Down><Home>    <Down><Home>      <Down><Home>      <Down><Home>    <Down><Home>  <Down><Esc>:wq<CR>

0 comments

#137 Guillaume Bonnoron / gbonnoron - Score: 103 - 12/30/10 @ 16:26
<Down><C-V><Down><Down><Down><Down><Down><Down><Down><Down>I  <Esc><Down><Right><Right>i  <Esc><Down><Left><Down><Right><Left><Down><C-V><Down><Down><Down>.i  <Left>I  <Esc><Right><Right><Down><C-V><Down>I  <Esc>ZZ

0 comments

#138 Ben Dowling / coderholic - Score: 120 - 12/31/10 @ 16:51
:%s/.*two/  \0/g<CR>:<Up><Left><Left><Left><Left>  <Left><Left><Left><Left><Left><BS><BS><BS>four<CR>:<Up><Left><Left><Left><Left>  <Home><Right><Right><Right><Right><Right><Del><Del><Del><Del>six<CR><Esc>:x<CR>

0 comments

#139 Andy Brett / andrewpbrett - Score: 170 - 12/30/10 @ 08:21
j  <Left><Left>i  <Down><Left><Left>    <Down><Left><Left><Left><Left>  <Down><Left><Left>  <Down><Left><Left>    <Down><Down><Up><Left><Left><Left><Left>      <Down><Left><Left><Left><Left><Left><Left>      <Down><Left><Left><Left><Left><Left><Left><Left>    <Down><Left><Left><Left><Left>  <Esc>:wq<CR>

0 comments

Created by: remi

139 active golfers, 381 entries

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

06/03/2012 at 09:24PM

21
#2 - Adam Bell / adamgbell

02/25/2013 at 01:56AM

21
#3 - Marco Hinz / _mhinz_

05/23/2013 at 12:26PM

21
#4 - Petro Тrouq / zulolosi

07/22/2013 at 05:13AM

21
#5 - John Braxler / braxler

05/16/2014 at 02:51PM

21
#6 - Ameen P / Ameen_P1

06/19/2016 at 11:01PM

23
#7 - Akira Matsuda / a_matsuda

01/05/2011 at 04:22PM

23
#8 - Wei Dai / clvv42

01/07/2011 at 03:47AM

23
#9 - vg / vimgolfer

02/26/2011 at 06:00PM

23
#10 - Justin Love / wondible

06/19/2011 at 04:57PM

23
#11 - You-Siang Lin / yslinnctu

12/01/2011 at 02:33PM

23
#12 - Alain Gilbert / alain_gilbert

12/15/2011 at 10:17PM

23
#13 - Pei-Lun Lee / ypcatw

01/18/2012 at 02:55AM

23
#14 - Renat Aksitov / Korvin79

02/23/2012 at 05:04PM

23
#15 - Rod Knowlton / codelahoma

05/27/2012 at 08:40PM

23
#16 - Conner McDaniel / connermcd

09/19/2012 at 04:14AM

23
#17 - Marcin Sza / coot_

11/27/2012 at 09:16PM

23
#18 - a24f0600 / a24f0600

01/23/2013 at 04:57PM

23
#19 - Trevor Powell / DoomedBunnies

03/20/2013 at 06:25AM

23
#20 - powertomato / powertomato

07/15/2013 at 01:12PM

23
#21 - Xelrifos / Xelrifos

02/27/2014 at 06:43PM

23
#22 - Jaakko Hannikainen / jgke_

09/08/2014 at 09:39PM

23
#23 - Lifepillar / lifepillar

06/27/2015 at 08:24PM

23
#24 - mark0829 / mark0829

07/13/2015 at 07:45AM

23
#25 - Walker Boh / walker_boh

12/09/2015 at 01:11PM

24
#26 - Matthew Draper / _matthewd

01/01/2011 at 03:54AM

24
#27 - Israel Chauca F. / Raimondi

01/01/2011 at 12:28PM

24
#28 - Tim Chase / gumnos

01/09/2011 at 03:23AM

24
#29 - Federico Galassi / federicogalassi

01/31/2011 at 12:09AM

24
#30 - Andrey Ivanov / Bytamine

08/15/2011 at 01:25PM

24
#31 - Albin Olsson / sentenser

01/16/2012 at 12:01AM

24
#32 - Hubba / HubbaBubbaFett

12/25/2012 at 09:41PM

24
#33 - Yann Moisan / YannMoisan

01/24/2013 at 10:33PM

24
#34 - Tyler / tylerbindon

04/01/2013 at 06:00AM

25
#35 - Will Gray / graywh

01/01/2011 at 12:38AM

25
#36 - Vincent Isambart / vincentisambart

01/01/2011 at 05:54AM

25
#37 - Prody / Prody225

01/01/2011 at 04:43PM

25
#38 - Gael / darkael2

01/09/2011 at 01:23PM

25
#39 - Pete Johns / johnsyweb

01/15/2011 at 03:09AM

25
#40 - dschobel / dschobel

02/20/2011 at 12:33AM

25
#41 - 無ん垢の叫び / john_ababa

02/23/2012 at 02:15PM

26
#42 - uuu / uu59

12/30/2010 at 01:33AM

26
#43 - Josh Weinberg / jcweinberg

12/30/2010 at 02:03AM

26
#44 - Behnam Esfahbod / zwnj

12/30/2010 at 11:34AM

26
#45 - Aaron Bull Schaefer / elasticdog

12/30/2010 at 05:34PM

26
#46 - milkypostman / milkypostman

12/31/2010 at 02:31PM

26
#47 - Martin Hauser / grummel

01/01/2011 at 05:02PM

26
#48 - Fer Enaf / 0x00C0FFEE

01/02/2011 at 08:36AM

26
#49 - ls lahrs / lslah

01/04/2011 at 07:52PM

26
#50 - Victor Vaile / victorv4_

01/05/2011 at 09:08AM

26
#51 - Sailesh Mittal / saileshmittal

01/14/2011 at 06:08PM

26
#52 - Jim Infield / jinfield

07/21/2011 at 03:04PM

26
#53 - Christopher Brew / Seph1rothVII

01/31/2012 at 01:44AM

26
#54 - Alex Hammel / AlexJHammel

12/24/2012 at 05:53PM

26
#55 - James / Dronak

09/05/2013 at 05:21PM

26
#56 - brett / brettyukich

09/29/2013 at 07:35PM

26
#57 - Daniel / Daniel00288663

04/05/2017 at 09:51AM

27
#58 - 藤田祥 / Sho Fujita / fujisho

12/31/2010 at 12:29PM

27
#59 - AD / golferTest101

01/01/2011 at 04:48PM

27
#60 - Philipp / klmann232

01/10/2011 at 12:29AM

27
#61 - Wesley Wong / wesleymwwong

01/30/2011 at 10:54AM

27
#62 - Jyun-Fan Tsai / fakecolor

02/15/2012 at 09:56AM

27
#63 - Kerson Hsiao / KersonHsiao

05/07/2012 at 10:37AM

27
#64 - RobertT / techrt2050

07/14/2013 at 08:57AM

27
#65 - Benjamin Williams / benjaminjosephw

01/11/2014 at 09:39PM

27
#66 - Joonas Pihlajamaa / jokkebk

02/21/2014 at 11:27AM

27
#67 - Jon Krause / jkrause314

12/17/2015 at 09:32PM

28
#68 - seth cousins / sethcousins

12/30/2010 at 03:10PM

28
#69 - Mikel Ward / mikelward

12/31/2010 at 01:52PM

28
#70 - Jesús Espino / jespinog

09/05/2011 at 10:56PM

28
#71 - Xavier Nayrac / lkdjiin

12/30/2011 at 01:52PM

28
#72 - cj / cj01101

02/03/2014 at 11:48PM

29
#73 - Brad Grzesiak / listrophy

12/30/2010 at 01:30AM

29
#74 - Isaiah Damron / Aenidye

12/30/2010 at 01:36AM

29
#75 - greg / kongo2002

12/31/2010 at 12:26AM

29
#76 - razvan dimescu / razvandimescu

12/31/2010 at 08:34AM

29
#77 - Leonard Chin / lchin

12/31/2010 at 10:17AM

29
#78 - emmanuel delgado / chischaschos

01/01/2011 at 07:04AM

29
#79 - Arto Vuori / dhpe

09/01/2012 at 07:43PM

29
#80 - George Angelopoulos / g_usermod

08/05/2016 at 02:24PM

30
#81 - Roland Crosby / roooooland

12/30/2010 at 08:19AM

30
#82 - Sam Saffron / samsaffron

12/30/2010 at 12:35PM

30
#83 - Fred Nias / frednias

12/30/2010 at 01:01PM

30
#84 - David Shaw / shawthings

12/30/2010 at 10:57PM

30
#85 - Johannes Martinsson / moxiba

12/30/2010 at 11:28PM

30
#86 - Sam Nardoni / samnardoni

12/31/2010 at 12:05AM

30
#87 - Juan C. Muller / juancmuller

12/31/2010 at 03:39AM

30
#88 - Joshua Flanagan / jflanagan

12/31/2010 at 11:35PM

30
#89 - Kyle Willmon / kylewillmon

01/01/2011 at 12:36AM

30
#90 - Marcin Ciunelis / martinciu

01/01/2011 at 06:42PM

30
#91 - Stuart Gale / bishboria

01/02/2011 at 07:36PM

30
#92 - Adam Pohorecki / apohorecki

01/04/2011 at 01:24PM

30
#93 - drio / drio

01/07/2011 at 01:04PM

30
#94 - fuck you / jerkassholeface

01/15/2011 at 12:47AM

30
#95 - Andrey A. Ugolnik / andreyugolnik

01/19/2011 at 10:13PM

30
#96 - Oleg Roshupkin / jjjahson

01/21/2011 at 09:39AM

30
#97 - mightyfoo / mightyfoo

05/26/2011 at 02:37PM

30
#98 - Emile Swarts / EmileSwarts

05/30/2011 at 07:56PM

30
#99 - Lauri Tirkkonen / lotheac

07/01/2011 at 10:06PM

30
#100 - jasper110 / jasper110

09/22/2011 at 09:42AM

30
#101 - William Dunand / wdunand

12/01/2011 at 03:41AM

30
#102 - Camilla Krag Jensen / naxoc

07/29/2012 at 12:16PM

30
#103 - Gregor Schmidt / schmidtwisser

10/01/2012 at 07:09PM

30
#104 - Ram Tamtam / ramtamtamtam

07/02/2014 at 01:28PM

31
#105 - Ricardo Sisnett / mrjackinc

01/03/2011 at 02:28AM

31
#106 - Thomas Schönwälder / Masei1988

01/11/2011 at 11:24PM

31
#107 - Francisco Dibar / frandibar

01/13/2011 at 03:55AM

31
#108 - Oliver Christ / 0liverChrist

02/27/2015 at 03:53PM

32
#109 - VitalyBerov / VitalyBerov

12/23/2012 at 01:17AM

32
#110 - mnx / mnxx

06/13/2014 at 09:44AM

33
#111 - Asmund Liseth / Asmund_L

12/31/2010 at 08:51AM

33
#112 - aimee / sermoa

01/09/2011 at 04:03PM

33
#113 - eholic / eholic

04/04/2011 at 12:30PM

33
#114 - Charlie Tanksley / charlietanksley

10/13/2011 at 04:13PM

33
#115 - Stefan Schmidt / stafue

12/06/2013 at 04:42PM

34
#116 - Jordi Romero / jordiromero

12/31/2010 at 03:59PM

34
#117 - Stefan Mai / iamnafets

09/16/2011 at 07:44AM

35
#118 - Amir Hedayaty / hedayaty

12/30/2010 at 12:14PM

35
#119 - Bob Corsaro / doki_pen

12/30/2010 at 05:11PM

37
#120 - Nicolas Friedli / NicolasFriedli

10/28/2012 at 07:17PM

38
#121 - Ben Brown / benofbrown

12/30/2010 at 07:09PM

39
#122 - Heron Medeiros / heronmedeiros

04/13/2014 at 02:56AM

40
#123 - Will Hardy / whrde

12/30/2010 at 03:07PM

40
#124 - Avinash Baliga / avinashbaliga

03/24/2011 at 11:59PM

41
#125 - Cássio Marques / cassiomarques

12/30/2010 at 11:50AM

42
#126 - Lee Marlow / lmarlow

01/01/2011 at 05:48AM

44
#127 - Ben Lenarts / benlenarts

01/03/2011 at 10:59PM

44
#128 - Dave / zzdave13

07/31/2011 at 09:16AM

45
#129 - Shaun Robinson / env

02/11/2014 at 03:36AM

50
#130 - Cyril Pascal / paxal

12/30/2010 at 05:57PM

52
#131 - Ragunathan Pattabi / rpattabi

05/10/2011 at 08:40AM

56
#132 - solsTiCe d'Hiver / solstice_dhiver

01/07/2014 at 05:57PM

60
#133 - alex scott / 4l3xsc0tt

12/30/2010 at 01:42AM

60
#134 - Dylan Beattie / dylanbeattie

12/30/2010 at 03:03PM

69
#135 - KMNK / kmnk

04/24/2011 at 07:39AM

92
#136 - Amit Kulkarni / amitkkulkarni

12/30/2010 at 07:30AM

103
#137 - Guillaume Bonnoron / gbonnoron

12/30/2010 at 04:26PM

120
#138 - Ben Dowling / coderholic

12/31/2010 at 04:51PM

170
#139 - Andy Brett / andrewpbrett

12/30/2010 at 08:21AM