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):
12
#151 - jsg / @jsg1122

06/13/2017 at 12:31AM

12
#152 - Robert Goeddel / @f0rdpr3fect

06/15/2017 at 10:41PM

12
#153 - Jon Doe / @JonDoe33157611

06/19/2017 at 01:57AM

12
#154 - Daniel Smith / @_Tysonzero

06/20/2017 at 05:15PM

12
#155 - el pollo diablo / @bjagojevich

06/21/2017 at 08:02PM

12
#156 - Michael Rees / @reesmichael1

06/22/2017 at 10:40PM

12
#157 - Julian Felix / @h4wked

06/27/2017 at 04:04PM

12
#158 - Ezra Zigmond / @ezrazig

06/27/2017 at 11:55PM

12
#159 - Sergio Semedi / @SergioSemedi

07/16/2017 at 01:18PM

12
#160 - Brandon Height / @Lask0x

08/08/2017 at 01:30AM

12
#161 - jirgn / @jirgn

09/24/2017 at 05:15PM

12
#162 - Geoff / @RealGeoffErwin

09/29/2017 at 01:38PM

12
#163 - Ron Alexssen / @Ralexhere

10/18/2017 at 04:27PM

12
#164 - Ahmed Hasan / @microbialwalrus

12/25/2017 at 06:24PM

12
#165 - Tim / @timothyscosta

04/08/2018 at 02:16PM

12
#166 - cds / @cdsudama

04/13/2018 at 07:55AM

12
#167 - 赤佐田奈葉 / @akasatanaha_

06/19/2018 at 04:44AM

12
#168 - Hugo / @szeyattai

08/20/2018 at 02:51AM

12
#169 - boredStudent / @boredStudent10

09/08/2018 at 11:44AM

13
#170 - Paul Ewing / @Wangledorf

05/26/2017 at 08:05AM

13
#171 - lpag / @lpag_ai

05/31/2017 at 08:54PM

13
#172 - squdle / @squdle

06/17/2017 at 01:16PM

13
#173 - grigouille / @grigouille2

07/05/2017 at 08:09PM

13
#174 - 黒澤亮二 / @rjkuro

07/22/2017 at 08:28AM

13
#175 - Marcin Paliwoda / @eukaliptuss

08/25/2017 at 01:54PM

13
#176 - Herr Joschka / @HerrJoschka

10/18/2017 at 04:49AM

13
#177 - Wayne / @lilwayne15561

11/28/2017 at 01:54AM

13
#178 - Akilan Anbalagan / @akilananb

03/27/2018 at 08:50AM

13
#179 - Jonathan Camilleri / @Too_Many_Taken

05/26/2018 at 12:21PM

13
#180 - Not real / @Notreal70353016

10/04/2018 at 02:48AM