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):
12
#271 - James Marshall / @astrophd

10/21/2022 at 03:11AM

12
#272 - Vinay Sridhar / @kewllip

03/19/2023 at 04:01PM

13
#273 - Paul Ewing / @Wangledorf

05/26/2017 at 08:05AM

13
#274 - Lukas Galke / @_lpag

05/31/2017 at 08:54PM

13
#275 - squdle / @squdle

06/17/2017 at 01:16PM

13
#276 - grigouille / @grigouille2

07/05/2017 at 08:09PM

13
#277 - 黒澤亮二 / @rjkuro

07/22/2017 at 08:28AM

13
#278 - Marcin Paliwoda / @eukaliptuss

08/25/2017 at 01:54PM

13
#279 - Herr Joschka / @HerrJoschka

10/18/2017 at 04:49AM

13
#280 - Wayne / @lilwayne15561

11/28/2017 at 01:54AM

13
#281 - Akilan Anbalagan / @akilananb

03/27/2018 at 08:50AM

13
#282 - Jonathan Camilleri / @Too_Many_Taken

05/26/2018 at 12:21PM

13
#283 - Not real / @Notreal70353016

10/04/2018 at 02:48AM

13
#284 - Jonny Wilson / @thejondom

12/27/2018 at 11:17PM

13
#285 - wrglprmft / @wrglprmft

01/19/2019 at 10:30PM

13
#286 - 默罕默德 / @Rt6RjEAJ987Woes

01/22/2019 at 12:51PM

13
#287 - StrangeNumbers / @NumbersStrange

03/28/2019 at 03:56AM

13
#288 - Vim Golfer / @VimGolfer6

08/23/2019 at 11:41AM

13
#289 - D. 👋 / @DCT_cpp

02/10/2022 at 08:34AM

14
#290 - k4 / @k4limschka

08/30/2017 at 01:06PM

14
#291 - Luis Rodriguez / @luisthecoder

11/14/2018 at 11:34PM

15
#292 - Eric Coleman / @EpicColeman

06/06/2017 at 06:48PM

17
#293 - Chris Bywater / @cbywater

05/26/2017 at 03:39PM

17
#294 - James Houghton / @jamesthoughton

05/26/2017 at 05:06PM

17
#295 - Anne Pacalet / @_Anne_P

07/06/2017 at 11:01AM

17
#296 - Gurukandhamoorthi / @Gurukandhamoor1

07/09/2017 at 03:18PM

17
#297 - Sean Earle / @Hell_Rok

05/07/2018 at 05:35AM

18
#298 - Ryan Coopersmith / @RyanCoopersmit1

06/03/2017 at 04:05PM

18
#299 - MGJoe93 / @mgjoe93

03/06/2019 at 01:22PM

18
#300 - Alex Koch 👨‍🍳👨‍💻🌹 / @alex_w_k

04/30/2019 at 04:51PM