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

144 active golfers, 405 entries

Leaderboard (lowest score wins):
21
#1 - Urtica dioica / @udioica

06/03/2012 at 09:24PM

21
#2 - Adam Bell / @adamgbell

02/25/2013 at 01:56AM

21
#3 - Marco Hinz / @_mhinz_

05/23/2013 at 12:26PM

21
#4 - Petro Тrouq / @zulolosi

07/22/2013 at 05:13AM

21
#5 - John Braxler / @braxler

05/16/2014 at 02:51PM

21
#6 - Ameen P / @Ameen_P1

06/19/2016 at 11:01PM

21
#7 - Turkey Man / @lvturkeyman

11/28/2017 at 05:38PM

21
#8 - DHM / @DHM29978992

05/21/2018 at 02:50AM

23
#9 - Akira Matsuda / @a_matsuda

01/05/2011 at 04:22PM

23
#10 - Wei Dai / @clvv42

01/07/2011 at 03:47AM

23
#11 - vg / @vimgolfer

02/26/2011 at 06:00PM

23
#12 - Justin Love / @wondible

06/19/2011 at 04:57PM

23
#13 - You-Siang Lin / @yslinnctu

12/01/2011 at 02:33PM

23
#14 - Alain Gilbert / @alain_gilbert

12/15/2011 at 10:17PM

23
#15 - Pei-Lun Lee / @ypcatw

01/18/2012 at 02:55AM

23
#16 - Renat Aksitov / @Korvin79

02/23/2012 at 05:04PM

23
#17 - Rod Knowlton / @codelahoma

05/27/2012 at 08:40PM

23
#18 - Conner McDaniel / @connermcd

09/19/2012 at 04:14AM

23
#19 - Marcin Sza / @coot_

11/27/2012 at 09:16PM

23
#20 - a24f0600 / @a24f0600

01/23/2013 at 04:57PM

23
#21 - Trevor Powell / @DoomedBunnies

03/20/2013 at 06:25AM

23
#22 - powertomato / @powertomato

07/15/2013 at 01:12PM

23
#23 - Xelrifos / @Xelrifos

02/27/2014 at 06:43PM

23
#24 - Jaakko Hannikainen / @jgke_

09/08/2014 at 09:39PM

23
#25 - Lifepillar / @lifepillar

06/27/2015 at 08:24PM

23
#26 - mark0829 / @mark0829

07/13/2015 at 07:45AM

23
#27 - Walker Boh / @walker_boh

12/09/2015 at 01:11PM

24
#28 - Matthew Draper / @_matthewd

01/01/2011 at 03:54AM

24
#29 - Israel Chauca F. / @Raimondi

01/01/2011 at 12:28PM

24
#30 - Tim Chase / @gumnos

01/09/2011 at 03:23AM