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

267 active golfers, 883 entries

Leaderboard (lowest score wins):
10
#151 - しぇぱっち / @shepabashi

10/22/2017 at 12:26AM

10
#152 - Vim Golf / @golf_vim

10/27/2017 at 12:35AM

10
#153 - Lisa Ugray / @lisa_ugray

03/16/2018 at 03:48PM

10
#154 - Guirec CORBEL / @GuirecCorbel

04/01/2018 at 01:03AM

10
#155 - Justin Hoyt / @JustinHoyt24

06/24/2018 at 02:44AM

10
#156 - Norbert / @mullno

07/01/2018 at 08:15PM

10
#157 - chaotic / @laersn

08/03/2018 at 01:13PM

10
#158 - Frank Korf / @OMGFrank

08/28/2018 at 09:42PM

10
#159 - Sebastien Mesili / @seb_kr

09/29/2018 at 05:03AM

10
#160 - vg / @vg53210350

10/28/2018 at 07:55PM

10
#161 - Mihai / @mihaicristiant

12/04/2018 at 12:59PM

10
#162 - churaki / @churaki

01/30/2019 at 11:58AM

10
#163 - Patrick Lavin / @LavinComputes

01/31/2019 at 02:55PM

10
#164 - Ng Sek Long / @NgSekLong

02/09/2019 at 04:51PM

10
#165 - Mateen Ulhaq / @sicariusnoctis

02/13/2019 at 05:26AM

10
#166 - Wei Wen / @goweiwen

02/14/2019 at 08:04PM

10
#167 - Zach Miller / @barizachsy

02/27/2019 at 03:57AM

10
#168 - Roger Stoltz / @rogsto1

03/05/2019 at 09:37PM

10
#169 - Vimfiz / @vimfiz

04/29/2019 at 08:42PM

10
#170 - Gitsnik / @dracyrys

05/04/2019 at 10:42AM

10
#171 - Arno / @arnoxmp

05/15/2019 at 04:34AM

10
#172 - albalitz / @_albalitz

06/07/2019 at 02:56PM

10
#173 - Ivo Blöchliger / @aigledesalpes

08/05/2019 at 02:09PM

10
#174 - vimRunnerUp3000 / @VUp3000

09/02/2019 at 06:32PM

10
#175 - Ariel Miculas / @ArielMiculas

09/26/2019 at 11:44AM

10
#176 - Abner jr / @Abnerjr19

09/29/2019 at 04:24AM

10
#177 - Lory / @Lory46845742

11/13/2019 at 09:24AM

11
#178 - tPenguinLTG / @tpenguinltg

05/25/2017 at 04:41AM

11
#179 - Anoop Kumar / @anooplive

05/25/2017 at 04:53AM

11
#180 - Benedikt Ames / @wisp3rwind

06/01/2017 at 03:17PM