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

179 active golfers, 527 entries

Leaderboard (lowest score wins):
9
#1 - Cristian Lupașcu / @clupasq

05/25/2017 at 06:16AM

9
#2 - Melvin Cheung / @MelvinCheung

05/25/2017 at 06:25AM

9
#3 - Smylers / @Smylers2

05/25/2017 at 06:43AM

9
#4 - Андрей / @andreyrmg

05/25/2017 at 06:46AM

9
#5 - Urtica dioica / @udioica

05/25/2017 at 06:54AM

9
#6 - John Braxler / @braxler

05/25/2017 at 11:26AM

9
#7 - Rodrigo Dorantes G. / @ruydg

05/25/2017 at 01:59PM

9
#8 - Saki Gw / @Sakigw

05/26/2017 at 09:14AM

9
#9 - David / @Revan4Vendetta

05/26/2017 at 10:23AM

9
#10 - Tomas Sikula / @tomsmicroblog

05/26/2017 at 12:31PM

9
#11 - no hodls barred / @AssafLavie

05/26/2017 at 01:56PM

9
#12 - ybw / @yossibenwolf

05/28/2017 at 09:40AM

9
#13 - Petro Тrouq / @zulolosi

05/28/2017 at 03:27PM

9
#14 - Zachary Neubert / @Mr_Saturn16347

05/28/2017 at 11:45PM

9
#15 - Stanislav / @prstad

05/29/2017 at 11:56AM

9
#16 - Kristian Haug / @krimhaug

05/29/2017 at 07:16PM

9
#17 - Vaughn Cato / @vaughncato

05/29/2017 at 08:50PM

9
#18 - Eloi S. Quesnel / @EloiSimardQ

05/30/2017 at 03:20AM

9
#19 - Christian Abbott / @etopixi

05/30/2017 at 11:43AM

9
#20 - TongHyun Kim / @crowdy

05/30/2017 at 01:45PM

9
#21 - Jye Sawtell-Rickson / @jsawtellrickson

05/31/2017 at 09:01AM

9
#22 - Marco Fontani / @mfontani

05/31/2017 at 03:49PM

9
#23 - Lukas Tobler / @lut0bler

06/03/2017 at 07:12PM

9
#24 - ssh89 / @ssh89

06/04/2017 at 01:30PM

9
#25 - Bruce Park / @bpark0

06/04/2017 at 10:44PM

9
#26 - 梧桐王子 / @WutongYujie

06/05/2017 at 05:04AM

9
#27 - .... / @coffman_r

06/07/2017 at 12:23AM

9
#28 - David Gustavsson / @mrGustaphe

06/08/2017 at 06:42AM

9
#29 - sebastian pech / @specht08

06/08/2017 at 12:30PM

9
#30 - Daniel Hjelm / @dhjelm

06/09/2017 at 05:10PM