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):
23
#31 - Xelrifos / @Xelrifos

02/27/2014 at 06:43PM

23
#32 - Jaakko Hannikainen / @jgke_

09/08/2014 at 09:39PM

23
#33 - Lifepillar / @lifepillar

06/27/2015 at 08:24PM

23
#34 - mark0829 / @mark0829

07/13/2015 at 07:45AM

23
#35 - Walker Boh / @walker_boh

12/09/2015 at 01:11PM

23
#36 - Mihai / @mihaicristiant

03/24/2019 at 12:11PM

24
#37 - Matthew Draper / @_matthewd

01/01/2011 at 03:54AM

24
#38 - Israel Chauca F. / @Raimondi

01/01/2011 at 12:28PM

24
#39 - Tim Chase / @gumnos

01/09/2011 at 03:23AM

24
#40 - Federico Galassi / @federicogalassi

01/31/2011 at 12:09AM

24
#41 - Andrey Ivanov / @Bytamine

08/15/2011 at 01:25PM

24
#42 - Albin Olsson / @sentenser

01/16/2012 at 12:01AM

24
#43 - Hubba / @HubbaBubbaFett

12/25/2012 at 09:41PM

24
#44 - Yann Moisan / @YannMoisan

01/24/2013 at 10:33PM

24
#45 - Tyler / @tylerbindon

04/01/2013 at 06:00AM

24
#46 - Denis Kaluznyy / @Spy_Denis

08/17/2017 at 03:44PM

24
#47 - garry quested / @GQuested

10/12/2021 at 08:54AM

24
#48 - Brando / @brandonce

01/29/2025 at 07:46AM

25
#49 - Will Gray / @graywh

01/01/2011 at 12:38AM

25
#50 - Vincent Isambart / @vincentisambart

01/01/2011 at 05:54AM

25
#51 - Prody / @Prody225

01/01/2011 at 04:43PM

25
#52 - Gael / @darkael2

01/09/2011 at 01:23PM

25
#53 - Pete Johns / @johnsyweb

01/15/2011 at 03:09AM

25
#54 - dschobel / @dschobel

02/20/2011 at 12:33AM

25
#55 - じょんあば / @john_ababa

02/23/2012 at 02:15PM

25
#56 - Bitt Faulk / @bittfaulk

03/13/2020 at 11:08PM

25
#57 - POSIX / @po6ix

01/23/2022 at 10:49AM

26
#58 - uuu / @uu59

12/30/2010 at 01:33AM

26
#59 - Josh Weinberg / @jcweinberg

12/30/2010 at 02:03AM

26
#60 - Behnam Esfahbod / @zwnj

12/30/2010 at 11:34AM