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

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 227 remaining solutions by signing in and submitting your own entry
#228 Thomas Gebert / @realtombert - Score: 35 - 09/29/17 @ 15:43
qa0i// <Esc>jq@a@@jqa0xxx<Esc>qj@@j@@<Esc><Esc>:wq<CR>

0 comments


Created by: @NjSlaughter

228 active golfers, 731 entries

Leaderboard (lowest score wins):
17
#211 - James Houghton / @jamesthoughton

05/26/2017 at 05:06PM

17
#212 - Anne Pacalet / @_Anne_P

07/06/2017 at 11:01AM

17
#213 - Gurukandhamoorthi / @Gurukandhamoor1

07/09/2017 at 03:18PM

17
#214 - Sean Earle / @Hell_Rok

05/07/2018 at 05:35AM

18
#215 - Ryan Coopersmith / @RyanCoopersmit1

06/03/2017 at 04:05PM

18
#216 - MGJoe93 / @mgjoe93

03/06/2019 at 01:22PM

19
#217 - Karl Hepler / @oldtimeguitar

05/25/2017 at 03:56PM

19
#218 - vimgolfer / @vimgolfinger

11/06/2017 at 01:24PM

19
#219 - Ntinos Mavrakis / @konmavrakis

05/04/2018 at 02:06PM

19
#220 - JT-Development.com / @JT_Development

03/04/2019 at 09:19AM

22
#221 - Paul Egy / @egy_paul

07/27/2018 at 05:34PM

22
#222 - Shunichi Kanade / @shunkana

12/02/2018 at 09:47AM

27
#223 - John Doe Jr / @bf4648

06/04/2017 at 05:29AM

27
#224 - JD Kaplan / @jedeleh

04/25/2018 at 02:30PM

27
#225 - Brent Woo / @BrentPWoo

10/02/2018 at 03:33PM

28
#226 - Nathan J Slaughter / @NjSlaughter

05/25/2017 at 04:11AM

31
#227 - Jurica / @Jurica34581259

11/16/2018 at 11:56AM

35
#228 - Thomas Gebert / @realtombert

09/29/2017 at 03:43PM