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 59265921e633730ce0000016

comment and uncomment code inline

It's very useful to be able to comment out a block of code in a quick edit. And likewise to uncomment the code. This operation often involves multi-line stanzas and even large blocks. With just line-wise navigation and insert mode this would cost you about 4 keystrokes per line. Master this hole of VimGolf and you'll quickly drop your key count in day to day Vim as well.

Start file
These first three lines should
be commented out with C-style
inline comments.

// These three lines should have
// the C-style insline comment 
// characters removed.
End file
// These first three lines should
// be commented out with C-style
// inline comments.

These three lines should have
the C-style insline comment 
characters removed.

View Diff

1,3c1,3
< These first three lines should
< be commented out with C-style
< inline comments.
---
> // These first three lines should
> // be commented out with C-style
> // inline comments.
5,7c5,7
< // These three lines should have
< // the C-style insline comment 
< // characters removed.
---
> These three lines should have
> the C-style insline comment 
> characters removed.

Solutions by @DakshaChatur:

Unlock 17 remaining solutions by signing in and submitting your own entry
Created by: @NjSlaughter

322 active golfers, 1122 entries

Solutions by @DakshaChatur:
9
#150 - Daksha Chatur / @DakshaChatur

09/26/2022 at 05:40AM

10
#>216 - Daksha Chatur / @DakshaChatur

09/26/2022 at 05:40AM

11
#>228 - Daksha Chatur / @DakshaChatur

09/26/2022 at 05:39AM

12
#>269 - Daksha Chatur / @DakshaChatur

09/26/2022 at 05:39AM

13
#>288 - Daksha Chatur / @DakshaChatur

09/26/2022 at 05:39AM

15
#>291 - Daksha Chatur / @DakshaChatur

09/26/2022 at 05:38AM

17
#>296 - Daksha Chatur / @DakshaChatur

09/26/2022 at 05:38AM

18
#>300 - Daksha Chatur / @DakshaChatur

09/26/2022 at 05:38AM

19
#>307 - Daksha Chatur / @DakshaChatur

09/26/2022 at 05:37AM

21
#>309 - Daksha Chatur / @DakshaChatur

09/26/2022 at 05:36AM

22
#>312 - Daksha Chatur / @DakshaChatur

09/26/2022 at 05:35AM

26
#>315 - Daksha Chatur / @DakshaChatur

09/26/2022 at 05:34AM

27
#>318 - Daksha Chatur / @DakshaChatur

09/26/2022 at 05:34AM

28
#>319 - Daksha Chatur / @DakshaChatur

09/26/2022 at 05:34AM

29
#>320 - Daksha Chatur / @DakshaChatur

09/26/2022 at 05:32AM

31
#>321 - Daksha Chatur / @DakshaChatur

09/26/2022 at 05:32AM

35
#>322 - Daksha Chatur / @DakshaChatur

09/26/2022 at 05:31AM