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):
26
#61 - Jim Infield / @jinfield

07/21/2011 at 03:04PM

26
#62 - Christopher Brew / @Seph1rothVII

01/31/2012 at 01:44AM

26
#63 - ajh / @AlexJHammel

12/24/2012 at 05:53PM

26
#64 - James / @Dronak

09/05/2013 at 05:21PM

26
#65 - brett / @brettyukich

09/29/2013 at 07:35PM

26
#66 - Daniel / @Daniel00288663

04/05/2017 at 09:51AM

26
#67 - majo senf / @majo_senf

07/06/2019 at 08:36PM

26
#68 - Marcel Funderák / @fundosh

03/04/2022 at 10:44PM

27
#69 - 藤田祥 / Sho Fujita / @fujisho

12/31/2010 at 12:29PM

27
#70 - AD / @golferTest101

01/01/2011 at 04:48PM

27
#71 - Philipp / @klmann232

01/10/2011 at 12:29AM

27
#72 - Wesley Wong / @wesleymwwong

01/30/2011 at 10:54AM

27
#73 - Jyun-Fan Tsai / @fakecolor

02/15/2012 at 09:56AM

27
#74 - Kerson Hsiao / @KersonHsiao

05/07/2012 at 10:37AM

27
#75 - RobertT / @techrt2050

07/14/2013 at 08:57AM

27
#76 - Benjamin Williams / @benjaminjosephw

01/11/2014 at 09:39PM

27
#77 - Joonas Pihlajamaa / @jokkebk

02/21/2014 at 11:27AM

27
#78 - Jon Krause / @jkrause314

12/17/2015 at 09:32PM

28
#79 - seth cousins / @sethcousins

12/30/2010 at 03:10PM

28
#80 - Mikel Ward / @mikelward

12/31/2010 at 01:52PM

28
#81 - Jesús Espino / @jespinog

09/05/2011 at 10:56PM

28
#82 - Xavier Nayrac / @lkdjiin

12/30/2011 at 01:52PM

28
#83 - cj / @cj01101

02/03/2014 at 11:48PM

29
#84 - Brad Grzesiak / @listrophy

12/30/2010 at 01:30AM

29
#85 - Isaiah Damron / @Aenidye

12/30/2010 at 01:36AM

29
#86 - greg / @kongo2002

12/31/2010 at 12:26AM

29
#87 - razvan dimescu / @razvandimescu

12/31/2010 at 08:34AM

29
#88 - Leonard Chin / @lchin

12/31/2010 at 10:17AM

29
#89 - emmanuel delgado / @chischaschos

01/01/2011 at 07:04AM

29
#90 - Arto Vuori / @dhpe

09/01/2012 at 07:43PM