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):
10
#121 - Pfhor / @PfhorShark

07/02/2017 at 02:53PM

10
#122 - Scott Mills / @smm1729

07/11/2017 at 03:31AM

10
#123 - Jacob Buete / @JBuete

07/20/2017 at 12:14PM

10
#124 - adeel hussain / @adeelhussain

07/31/2017 at 06:15AM

10
#125 - Will / @obiwan__k3n00bi

08/05/2017 at 03:54AM

10
#126 - Elton Kamami / @pixel_grid

10/09/2017 at 08:29PM

10
#127 - しぇぱっち / @shepabashi

10/22/2017 at 12:26AM

10
#128 - Vim Golf / @golf_vim

10/27/2017 at 12:35AM

10
#129 - Lisa Ugray / @lisa_ugray

03/16/2018 at 03:48PM

10
#130 - Guirec CORBEL / @GuirecCorbel

04/01/2018 at 01:03AM

10
#131 - Justin Hoyt / @JustinHoyt24

06/24/2018 at 02:44AM

10
#132 - Norbert / @mullno

07/01/2018 at 08:15PM

10
#133 - chaotic / @laersn

08/03/2018 at 01:13PM

10
#134 - Frank Korf / @OMGFrank

08/28/2018 at 09:42PM

10
#135 - Sebastien Mesili / @seb_kr

09/29/2018 at 05:03AM

10
#136 - vg / @vg53210350

10/28/2018 at 07:55PM

11
#137 - tPenguinLTG / @tpenguinltg

05/25/2017 at 04:41AM

11
#138 - Anoop Kumar / @anooplive

05/25/2017 at 04:53AM

11
#139 - Benedikt Ames / @wisp3rwind

06/01/2017 at 03:17PM

11
#140 - Laurent Atlan / @laurentatlan1

09/10/2017 at 07:00PM

11
#141 - niwatoco / @yoshitune9

07/19/2018 at 07:48PM

12
#142 - AleksandarTrifunovic / @akstrfn

05/25/2017 at 03:46PM

12
#143 - Cristian / @cris_perez_b

05/26/2017 at 08:29AM

12
#144 - squid / @zerosquid

05/26/2017 at 11:50PM

12
#145 - jakeroberts / @jakeroberts

05/27/2017 at 07:31PM

12
#146 - duke of garda / @dukeofgarda

05/29/2017 at 07:32PM

12
#147 - Edouard Piette / @EdPiette

05/30/2017 at 11:41AM

12
#148 - James / @Dronak

05/31/2017 at 01:15AM

12
#149 - Davis Fields / @i301585

06/09/2017 at 04:37AM

12
#150 - Ayman Farhat / @aymanfarhat

06/11/2017 at 11:28AM