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

323 active golfers, 1124 entries

Leaderboard (lowest score wins):
18
#301 - drGsus / @drGsus

08/04/2020 at 08:28AM

18
#302 - vimgolfaccfekxh / @vimgolfaccfekxh

10/19/2022 at 11:53PM

18
#303 - luke37842 / @luke37842

05/14/2024 at 06:38PM

19
#304 - Karl Hepler / @oldtimeguitar

05/25/2017 at 03:56PM

19
#305 - vimgolfer / @vimgolfinger

11/06/2017 at 01:24PM

19
#306 - Ntinos Mavrakis / @konmavrakis

05/04/2018 at 02:06PM

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

03/04/2019 at 09:19AM

19
#308 - Adrien / @beudbeud

08/17/2019 at 08:26AM

19
#309 - かみひろ / @km_hr

03/04/2024 at 02:44PM

21
#310 - Kaustubh Murumkar / @k_austub_h

09/26/2020 at 12:50AM

22
#311 - Paul Egy / @egy_paul

07/27/2018 at 05:34PM

22
#312 - Shunichi Kanade / @shunkana

12/02/2018 at 09:47AM

22
#313 - Rustem B. / @_rustemb

07/31/2020 at 02:08PM

25
#314 - MojoLake / @vim_golf1

08/01/2023 at 10:11AM

26
#315 - Phoon / @justflashhim

05/10/2019 at 10:43PM

26
#316 - Aaron / @_Lordofthevoid_

12/01/2019 at 02:13PM

27
#317 - John Doe Jr / @bf4648

06/04/2017 at 05:29AM

27
#318 - JD Kaplan / @jedeleh

04/25/2018 at 02:30PM

27
#319 - Brent Woo / @BrentPWoo

10/02/2018 at 03:33PM

28
#320 - Nathan Slaughter / @NjSlaughter

05/25/2017 at 04:11AM

29
#321 - GrimmT / @GrimmT10

11/02/2019 at 10:19AM

31
#322 - Jurica / @Jurica34581259

11/16/2018 at 11:56AM

35
#323 - Thomas Gebert / @realtombert

09/29/2017 at 03:43PM