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

177 active golfers, 534 entries

Leaderboard (lowest score wins):
20
#1 - Peppa Pig / @PeppaPi95550250

07/03/2024 at 08:45AM

21
#2 - Urtica dioica / @udioica

06/03/2012 at 09:24PM

21
#3 - Adam Bell / @adamgbell

02/25/2013 at 01:56AM

21
#4 - Marco Hinz / @_mhinz_

05/23/2013 at 12:26PM

21
#5 - Petro Тrouq / @zulolosi

07/22/2013 at 05:13AM

21
#6 - John Braxler / @braxler

05/16/2014 at 02:51PM

21
#7 - Ameen P / @Ameen_P1

06/19/2016 at 11:01PM

21
#8 - Turkey Man / @lvturkeyman

11/28/2017 at 05:38PM

21
#9 - DHM / @DHM29978992

05/21/2018 at 02:50AM

21
#10 - blabla zincou / @BZincou

03/04/2022 at 10:18PM

21
#11 - Zion Park / @zionpark93

01/10/2023 at 12:42PM

21
#12 - Alex Lewin / @_AlexLewin

02/22/2023 at 06:30AM

21
#13 - tch1001 / @tch1001

07/18/2023 at 05:47PM

21
#14 - nickGPT / @nickandbro

08/28/2024 at 11:55PM

22
#15 - Jean George / @JeanGeo20504212

05/16/2022 at 07:20AM

23
#16 - Akira Matsuda / @a_matsuda

01/05/2011 at 04:22PM

23
#17 - Wei Dai / @clvv42

01/07/2011 at 03:47AM

23
#18 - vg / @vimgolfer

02/26/2011 at 06:00PM

23
#19 - Justin Love / @wondible

06/19/2011 at 04:57PM

23
#20 - You-Siang Lin / @yslinnctu

12/01/2011 at 02:33PM

23
#21 - Alain Gilbert / @alain_gilbert

12/15/2011 at 10:17PM

23
#22 - Pei-Lun Lee / @ypcatw

01/18/2012 at 02:55AM

23
#23 - Renat Aksitov / @Korvin79

02/23/2012 at 05:04PM

23
#24 - Rod Knowlton / @codelahoma

05/27/2012 at 08:40PM

23
#25 - Conner McDaniel / @connermcd

09/19/2012 at 04:14AM

23
#26 - Marcin Szamotulski / @me_coot

11/27/2012 at 09:16PM

23
#27 - a24f0600 / @a24f0600

01/23/2013 at 04:57PM

23
#28 - Trevor Powell / @DoomedBunnies

03/20/2013 at 06:25AM

23
#29 - powertomato / @powertomato

07/15/2013 at 01:12PM

23
#30 - Xelrifos / @Xelrifos

02/27/2014 at 06:43PM