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 by @_AlexLewin:

Unlock 19 remaining solutions by signing in and submitting your own entry
Created by: @remi

178 active golfers, 542 entries

Solutions by @_AlexLewin:
21
#12 - Alex Lewin / @_AlexLewin

02/22/2023 at 06:30AM

21
#>12 - Alex Lewin / @_AlexLewin

02/22/2023 at 06:31AM

21
#>12 - Alex Lewin / @_AlexLewin

02/22/2023 at 06:39AM

21
#>12 - Alex Lewin / @_AlexLewin

02/22/2023 at 06:40AM

22
#>16 - Alex Lewin / @_AlexLewin

02/22/2023 at 06:29AM

23
#>36 - Alex Lewin / @_AlexLewin

02/22/2023 at 06:29AM

23
#>36 - Alex Lewin / @_AlexLewin

02/22/2023 at 06:33AM

23
#>36 - Alex Lewin / @_AlexLewin

02/22/2023 at 06:38AM

24
#>47 - Alex Lewin / @_AlexLewin

02/22/2023 at 06:28AM

24
#>47 - Alex Lewin / @_AlexLewin

02/22/2023 at 06:35AM

25
#>56 - Alex Lewin / @_AlexLewin

02/22/2023 at 06:28AM

26
#>74 - Alex Lewin / @_AlexLewin

02/22/2023 at 06:25AM

26
#>74 - Alex Lewin / @_AlexLewin

02/22/2023 at 06:27AM

26
#>74 - Alex Lewin / @_AlexLewin

02/22/2023 at 06:34AM

27
#>85 - Alex Lewin / @_AlexLewin

02/22/2023 at 06:24AM

27
#>85 - Alex Lewin / @_AlexLewin

02/22/2023 at 06:37AM

28
#>91 - Alex Lewin / @_AlexLewin

02/22/2023 at 06:22AM

29
#>100 - Alex Lewin / @_AlexLewin

02/22/2023 at 06:21AM

31
#>131 - Alex Lewin / @_AlexLewin

02/22/2023 at 06:17AM