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):
9
#91 - platypusDancing / @platypusDancing

05/03/2018 at 05:47AM

9
#92 - 石奕心 / @allenshih1

06/11/2018 at 08:35PM

9
#93 - Mono Ruiz / @ElMonoRuiz

06/20/2018 at 09:59PM

9
#94 - Daniël De Koker / @daniel_koker

07/01/2018 at 09:28PM

9
#95 - Chris Dean / @ChrisDe62379742

07/11/2018 at 05:28PM

9
#96 - qed / @qed13308565

07/25/2018 at 04:40PM

9
#97 - d8d90d / @d8d90d

08/18/2018 at 11:31PM

9
#98 - fucus / @fishlovebanana

08/19/2018 at 08:04AM

9
#99 - Frank Rifk / @r1fk

08/31/2018 at 04:43PM

9
#100 - Jeff / @sir_wiggles3

09/09/2018 at 06:31AM

9
#101 - Bart3k / @Bart3k3

09/12/2018 at 07:32AM

9
#102 - Rasmus Bergström / @JRasmusBm

09/29/2018 at 09:48PM

9
#103 - Roger Bongers / @RogerBongers

10/05/2018 at 09:10PM

9
#104 - Benjamin Kiesl / @BenjaminKiesl

10/20/2018 at 02:55PM

9
#105 - Sxcy / @SxcyX

10/22/2018 at 02:40PM

9
#106 - Di Peng / @DCodier

11/01/2018 at 10:22PM

9
#107 - Dax / @zacoxi

11/09/2018 at 05:44AM

9
#108 - name / @name65894813

11/19/2018 at 03:50PM

10
#109 - Victor Ramirez / @virako

05/31/2017 at 09:05PM

10
#110 - martin tourneboeuf / @martintournebo1

06/01/2017 at 05:47PM

10
#111 - Sergey Lisakov / @pozitron57

06/06/2017 at 08:19PM

10
#112 - Harsh Kumar / @datsleepyguy

06/07/2017 at 05:58PM

10
#113 - Benoit Tigeot / @Benoit_Tgt

06/08/2017 at 04:49PM

10
#114 - Carl Egbert / @CarlOEgbert

06/09/2017 at 05:51AM

10
#115 - Robert Mosher / @rcmosher

06/15/2017 at 05:26PM

10
#116 - John Smith / @john828495

06/16/2017 at 02:01PM

10
#117 - John Smith / @johns32768

06/16/2017 at 06:46PM

10
#118 - Tom Sisk / @TomSisk

06/21/2017 at 12:43AM

10
#119 - Kieron Browne / @KieronBrowne1

06/30/2017 at 08:04AM

10
#120 - Ben Hill / @KaizenSoze70

06/30/2017 at 12:40PM