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

323 active golfers, 1124 entries

Leaderboard (lowest score wins):
12
#241 - Robert Goeddel / @f0rdpr3fect

06/15/2017 at 10:41PM

12
#242 - Jon Doe / @JonDoe33157611

06/19/2017 at 01:57AM

12
#243 - Daniel Smith / @_Tysonzero

06/20/2017 at 05:15PM

12
#244 - el pollo diablo / @bjagojevich

06/21/2017 at 08:02PM

12
#245 - Michael Rees / @reesmichael1

06/22/2017 at 10:40PM

12
#246 - Julian Felix / @h4wked

06/27/2017 at 04:04PM

12
#247 - Ezra Zigmond / @ezrazig

06/27/2017 at 11:55PM

12
#248 - Sergio Semedi / @SergioSemedi

07/16/2017 at 01:18PM

12
#249 - Brandon Height / @Lask0x

08/08/2017 at 01:30AM

12
#250 - jirgn / @jirgn

09/24/2017 at 05:15PM

12
#251 - Geoff / @RealGeoffErwin

09/29/2017 at 01:38PM

12
#252 - Ron Alexssen / @Ralexhere

10/18/2017 at 04:27PM

12
#253 - Ahmed Hasan / @ahmedrhasan

12/25/2017 at 06:24PM

12
#254 - Tim / @timothyscosta

04/08/2018 at 02:16PM

12
#255 - amal / @cdsudama

04/13/2018 at 07:55AM

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

06/19/2018 at 04:44AM

12
#257 - Hugo / @szeyattai

08/20/2018 at 02:51AM

12
#258 - boredStudent / @boredStudent10

09/08/2018 at 11:44AM

12
#259 - timonegk / @timonegk

11/25/2018 at 08:29PM

12
#260 - diwa / @Di_nate_

12/14/2018 at 07:36AM

12
#261 - Oren Koriat / @KoriatOren

01/18/2019 at 07:00PM

12
#262 - Paul Inc / @hiniol1982

02/24/2019 at 09:58AM

12
#263 - Der Wucher / @derwucher

03/02/2019 at 06:16PM

12
#264 - Groovy / @groovy9

03/08/2019 at 04:35PM

12
#265 - zenwalker / @zenwalker93

03/11/2019 at 02:08PM

12
#266 - ahm4711 / @ahm4711

03/14/2019 at 09:28PM

12
#267 - Jeremiah Smith / @jeremiah4smith

04/11/2019 at 01:31AM

12
#268 - Henry Wang (theKidOfArcrania) / @kidOfArcrania

05/24/2019 at 08:38PM

12
#269 - Chris G / @AboutThatThing

06/10/2019 at 08:14PM

12
#270 - Aioriya / @AioriyaDonk

09/02/2019 at 08:14PM