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

200 active golfers, 621 entries

Leaderboard (lowest score wins):
9
#61 - Terry Ding / @TerryDing77

08/23/2017 at 07:49PM

9
#62 - harpocrates744 / @harpocrates744

09/05/2017 at 08:34PM

9
#63 - zava / @znl1087

09/07/2017 at 10:17AM

9
#64 - Дима / @dimkino

09/07/2017 at 04:04PM

9
#65 - bazkila@gmail.com / @bazkila

09/08/2017 at 08:10AM

9
#66 - Cary Goltermann / @CaryGoltermann

09/25/2017 at 04:59PM

9
#67 - Charlie OConor / @charlieoconor

09/29/2017 at 06:27AM

9
#68 - Luke Bryant / @LukeBryant55

10/01/2017 at 10:47PM

9
#69 - Le Lycal / @LeLycal

10/07/2017 at 08:45AM

9
#70 - Turkey Man / @lvturkeyman

11/08/2017 at 02:57PM

9
#71 - Benoit Mortgat / @Benoit_Mortgat

11/14/2017 at 08:54AM

9
#72 - Bradley M. Small / @BradleySmall

11/20/2017 at 01:04PM

9
#73 - BareTull / @BareTull3

12/04/2017 at 01:55PM

9
#74 - Sage san / @sagesancast

12/20/2017 at 02:09PM

9
#75 - Luke Parsons / @lukeparsons

12/29/2017 at 01:16PM

9
#76 - BarbaJol / @drpproteus

12/31/2017 at 10:14AM

9
#77 - maks kamnikar / @maks_kamnikar

01/07/2018 at 11:22PM

9
#78 - Sebastian Wieland / @oktupol

01/19/2018 at 02:50PM

9
#79 - ParasamGateZero / @ParasamGateZero

01/22/2018 at 05:34AM

9
#80 - Dominic Z / @thammaaa

01/25/2018 at 10:40AM

9
#81 - Simon Cheng / @bambooraccoon

01/26/2018 at 04:50PM

9
#82 - c0llision / @sh3llcode

01/27/2018 at 07:35PM

9
#83 - brandon salmon / @Exiledz

01/28/2018 at 10:47AM

9
#84 - bocadillodeatun / @bocadillodeatun

01/28/2018 at 02:22PM

9
#85 - Arijus / @argshook

02/09/2018 at 09:47AM

9
#86 - Veljko Dimic / @v2dimic

02/12/2018 at 02:09PM

9
#87 - GreenPinguin / @GreenPinguin2

03/12/2018 at 04:02PM

9
#88 - vimthrowaway / @vimgolf_throw

04/08/2018 at 01:45PM

9
#89 - DHM / @DHM29978992

04/14/2018 at 04:19AM

9
#90 - radrhin / @radrhin

04/20/2018 at 04:10PM