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

147 active golfers, 416 entries

Leaderboard (lowest score wins):
33
#121 - Stefan Schmidt / @stafue

12/06/2013 at 04:42PM

34
#122 - Jordi Romero / @jordiromero

12/31/2010 at 03:59PM

34
#123 - Stefan Mai / @iamnafets

09/16/2011 at 07:44AM

35
#124 - Amir Hedayaty / @hedayaty

12/30/2010 at 12:14PM

35
#125 - Bob Corsaro / @doki_pen

12/30/2010 at 05:11PM

37
#126 - Nicolas Friedli / @NicolasFriedli

10/28/2012 at 07:17PM

38
#127 - Ben Brown / @benofbrown

12/30/2010 at 07:09PM

39
#128 - Heron Medeiros / @heronmedeiros

04/13/2014 at 02:56AM

40
#129 - Will Hardy / @whrde

12/30/2010 at 03:07PM

40
#130 - Avinash Baliga / @avinashbaliga

03/24/2011 at 11:59PM

41
#131 - Cássio Marques / @cassiomarques

12/30/2010 at 11:50AM

42
#132 - Lee Marlow / @lmarlow

01/01/2011 at 05:48AM

42
#133 - Brent Woo / @BrentPWoo

10/16/2018 at 07:57PM

44
#134 - Ben Lenarts / @benlenarts

01/03/2011 at 10:59PM

44
#135 - Dave / @zzdave13

07/31/2011 at 09:16AM

45
#136 - Shaun Robinson / @env

02/11/2014 at 03:36AM

47
#137 - Gurukandhamoorthi / @Gurukandhamoor1

08/12/2017 at 03:46PM

50
#138 - Cyril Pascal / @paxal

12/30/2010 at 05:57PM

52
#139 - Ragunathan Pattabi / @rpattabi

05/10/2011 at 08:40AM

56
#140 - solsTiCe d'Hiver / @solstice_dhiver

01/07/2014 at 05:57PM

60
#141 - alex scott / @4l3xsc0tt

12/30/2010 at 01:42AM

60
#142 - Dylan Beattie / @dylanbeattie

12/30/2010 at 03:03PM

69
#143 - KMNK / @kmnk

04/24/2011 at 07:39AM

92
#144 - Amit Kulkarni / @amitkkulkarni

12/30/2010 at 07:30AM

103
#145 - Guillaume Bonnoron / @gbonnoron

12/30/2010 at 04:26PM

120
#146 - Ben Dowling / @coderholic

12/31/2010 at 04:51PM

170
#147 - Andy Brett / @andrewpbrett

12/30/2010 at 08:21AM