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):
32
#121 - mnx / @mnxx

06/13/2014 at 09:44AM

32
#122 - SplinterPie / @splinter_pie

05/04/2018 at 11:18AM

32
#123 - Brendan Schaenzer / @bschaenzer

09/30/2020 at 09:03PM

32
#124 - Michael / @triorph

11/12/2021 at 07:21AM

32
#125 - Auri Iodide / @auri_iodide

03/06/2022 at 08:44AM

33
#126 - Asmund / @herrasbe

12/31/2010 at 08:51AM

33
#127 - aimee / @sermoa

01/09/2011 at 04:03PM

33
#128 - eholic / @eholic

04/04/2011 at 12:30PM

33
#129 - Charlie Tanksley / @charlietanksley

10/13/2011 at 04:13PM

33
#130 - Stefan Schmidt / @stafue

12/06/2013 at 04:42PM

34
#131 - Jordi Romero / @jordiromero

12/31/2010 at 03:59PM

34
#132 - Stefan Mai / @iamnafets

09/16/2011 at 07:44AM

35
#133 - Amir Hedayaty / @hedayaty

12/30/2010 at 12:14PM

35
#134 - Bob Corsaro / @doki_pen

12/30/2010 at 05:11PM

37
#135 - Nicolas Friedli / @NicolasFriedli

10/28/2012 at 07:17PM

38
#136 - Ben Brown / @benofbrown

12/30/2010 at 07:09PM

39
#137 - Heron Medeiros / @heronmedeiros

04/13/2014 at 02:56AM

40
#138 - Will Hardy / @whrde

12/30/2010 at 03:07PM

40
#139 - Avinash Baliga / @avinashbaliga

03/24/2011 at 11:59PM

41
#140 - Cássio Marques / @cassiomarques

12/30/2010 at 11:50AM

42
#141 - Lee Marlow / @lmarlow

01/01/2011 at 05:48AM

42
#142 - Brent Woo / @BrentPWoo

10/16/2018 at 07:57PM

43
#143 - Ted Kruijff / @kalkran

04/15/2022 at 09:21AM

44
#144 - Ben Lenarts / @benlenarts

01/03/2011 at 10:59PM

44
#145 - Dave / @zzdave13

07/31/2011 at 09:16AM

45
#146 - Shaun Robinson / @env

02/11/2014 at 03:36AM

45
#147 - shahanavaz m / @shahanavazm

02/14/2022 at 04:41AM

47
#148 - Gurukandhamoorthi / @Gurukandhamoor1

08/12/2017 at 03:46PM

50
#149 - Cyril Pascal / @paxal

12/30/2010 at 05:57PM

52
#150 - Ragunathan Pattabi / @rpattabi

05/10/2011 at 08:40AM