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 157 remaining solutions by signing in and submitting your own entry
#158 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

158 active golfers, 443 entries

Leaderboard (lowest score wins):
24
#31 - Matthew Draper / @_matthewd

01/01/2011 at 03:54AM

24
#32 - Israel Chauca F. / @Raimondi

01/01/2011 at 12:28PM

24
#33 - Tim Chase / @gumnos

01/09/2011 at 03:23AM

24
#34 - Federico Galassi / @federicogalassi

01/31/2011 at 12:09AM

24
#35 - Andrey Ivanov / @Bytamine

08/15/2011 at 01:25PM

24
#36 - Albin Olsson / @sentenser

01/16/2012 at 12:01AM

24
#37 - Hubba / @HubbaBubbaFett

12/25/2012 at 09:41PM

24
#38 - Yann Moisan / @YannMoisan

01/24/2013 at 10:33PM

24
#39 - Tyler / @tylerbindon

04/01/2013 at 06:00AM

24
#40 - Denis Kaluznyy / @Spy_Denis

08/17/2017 at 03:44PM

24
#41 - garry quested / @GQuested

10/12/2021 at 08:54AM

25
#42 - Will Gray / @graywh

01/01/2011 at 12:38AM

25
#43 - Vincent Isambart / @vincentisambart

01/01/2011 at 05:54AM

25
#44 - Prody / @Prody225

01/01/2011 at 04:43PM

25
#45 - Gael / @darkael2

01/09/2011 at 01:23PM

25
#46 - Pete Johns / @johnsyweb

01/15/2011 at 03:09AM

25
#47 - dschobel / @dschobel

02/20/2011 at 12:33AM

25
#48 - 無ん垢の叫び / @john_ababa

02/23/2012 at 02:15PM

25
#49 - Bitt Faulk / @bittfaulk

03/13/2020 at 11:08PM

25
#50 - POSIX / @po6ix

01/23/2022 at 10:49AM

26
#51 - uuu / @uu59

12/30/2010 at 01:33AM

26
#52 - Josh Weinberg / @jcweinberg

12/30/2010 at 02:03AM

26
#53 - Behnam Esfahbod / @zwnj

12/30/2010 at 11:34AM

26
#54 - Aaron Bull Schaefer / @elasticdog

12/30/2010 at 05:34PM

26
#55 - milkypostman / @milkypostman

12/31/2010 at 02:31PM

26
#56 - Martin Hauser / @grummel

01/01/2011 at 05:02PM

26
#57 - Fer Enaf / @0x00C0FFEE

01/02/2011 at 08:36AM

26
#58 - ls lahrs / @lslah

01/04/2011 at 07:52PM

26
#59 - Victor Vaile / @victorv4_

01/05/2011 at 09:08AM

26
#60 - Sailesh Mittal / @saileshmittal

01/14/2011 at 06:08PM