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):
9
#121 - Chester Yap / @Chest_ErYap

07/22/2019 at 11:55AM

9
#122 - Miłosz Łakomy / @foobar01123

07/26/2019 at 11:49AM

9
#123 - sooqua / @sooqua

08/09/2019 at 04:48AM

9
#124 - theBecwar / @thebecwar

08/19/2019 at 05:44PM

9
#125 - Brandon Harrison / @llAboutB

09/24/2019 at 10:18PM

9
#126 - Viktor Styrud / @ViktorStyrud

10/10/2019 at 12:24PM

9
#127 - vimgolfer / @vimgolfer7

10/22/2019 at 02:01AM

9
#128 - Mario Olofo / @mario_olofo

10/23/2019 at 10:57PM

9
#129 - leo / @leo28356948

11/15/2019 at 02:13AM

9
#130 - James Casey / @hanavi

12/22/2019 at 12:20AM

9
#131 - Delon / @delonleonard

01/05/2020 at 06:38AM

9
#132 - 임덕윤 / @SnLHUF5ZYJXqI1m

01/05/2020 at 01:12PM

10
#133 - Victor Ramirez / @virako

05/31/2017 at 09:05PM

10
#134 - martin tourneboeuf / @martintournebo1

06/01/2017 at 05:47PM

10
#135 - Sergey Lisakov / @pozitron57

06/06/2017 at 08:19PM

10
#136 - Harsh Kumar / @datsleepyguy

06/07/2017 at 05:58PM

10
#137 - Benoit Benoit / @Benoit_Tgt

06/08/2017 at 04:49PM

10
#138 - Carl Egbert / @CarlOEgbert

06/09/2017 at 05:51AM

10
#139 - Robert Mosher / @rcmosher

06/15/2017 at 05:26PM

10
#140 - John Smith / @john828495

06/16/2017 at 02:01PM

10
#141 - John Smith / @johns32768

06/16/2017 at 06:46PM

10
#142 - Tom Sisk / @TomSisk

06/21/2017 at 12:43AM

10
#143 - Kieron Browne / @KieronBrowne1

06/30/2017 at 08:04AM

10
#144 - Ben Hill / @KaizenSoze70

06/30/2017 at 12:40PM

10
#145 - Pfhor / @PfhorShark

07/02/2017 at 02:53PM

10
#146 - Scott Mills / @smm1729

07/11/2017 at 03:31AM

10
#147 - Jacob Buete / @JBuete

07/20/2017 at 12:14PM

10
#148 - adeel hussain / @adeelhussain

07/31/2017 at 06:15AM

10
#149 - Will / @obiwan__k3n00bi

08/05/2017 at 03:54AM

10
#150 - Elton Kamami / @pixel_grid

10/09/2017 at 08:29PM