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 doesnt 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 doesnt 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 179 remaining solutions by signing in and submitting your own entry
#180 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

180 active golfers, 550 entries

Leaderboard (lowest score wins):
30
#121 - jasper110 / @jasper110

09/22/2011 at 09:42AM

30
#122 - William Dunand / @wdunand

12/01/2011 at 03:41AM

30
#123 - Camilla Krag Jensen / @naxoc

07/29/2012 at 12:16PM

30
#124 - Gregor Schmidt / @schmidtwisser

10/01/2012 at 07:09PM

30
#125 - Ram Tamtam / @ramtamtamtam

07/02/2014 at 01:28PM

30
#126 - quemeraisc / @quemeraisc

05/24/2022 at 12:50PM

30
#127 - shahanavaz m / @shahanavazm

02/22/2024 at 11:45PM

30
#128 - Cameron Thomas / @cthom055

07/30/2024 at 10:49PM

31
#129 - El Jacko / @mrjackinc

01/03/2011 at 02:28AM

31
#130 - Thomas Schönwälder / @Masei1988

01/11/2011 at 11:24PM

31
#131 - Francisco Dibar / @frandibar

01/13/2011 at 03:55AM

31
#132 - Oliver Christ / @0liverChrist

02/27/2015 at 03:53PM

32
#133 - VitalyBerov / @VitalyBerov

12/23/2012 at 01:17AM

32
#134 - mnx / @mnxx

06/13/2014 at 09:44AM

32
#135 - SplinterPie / @splinter_pie

05/04/2018 at 11:18AM

32
#136 - Brendan Schaenzer / @bschaenzer

09/30/2020 at 09:03PM

32
#137 - Michael / @triorph

11/12/2021 at 07:21AM

32
#138 - Auri Iodide / @auri_iodide

03/06/2022 at 08:44AM

32
#139 - Colin Benner / @yzhs

01/12/2025 at 04:50PM

33
#140 - Asmund / @herrasbe

12/31/2010 at 08:51AM

33
#141 - aimee / @sermoa

01/09/2011 at 04:03PM

33
#142 - eholic / @eholic

04/04/2011 at 12:30PM

33
#143 - Charlie Tanksley / @charlietanksley

10/13/2011 at 04:13PM

33
#144 - Stefan Schmidt / @stafue

12/06/2013 at 04:42PM

33
#145 - Spam Mail / @mrfdot

05/26/2023 at 01:55AM

34
#146 - Jordi Romero / @jordiromero

12/31/2010 at 03:59PM

34
#147 - Stefan Mai / @iamnafets

09/16/2011 at 07:44AM

35
#148 - Amir Hedayaty / @hedayaty

12/30/2010 at 12:14PM

35
#149 - Bob Corsaro / @doki_pen

12/30/2010 at 05:11PM

35
#150 - Qing Liu / @poeminlash

09/20/2022 at 03:25AM