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):
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

9
#109 - band / @band26376522

01/26/2019 at 08:36PM

9
#110 - Sebastien Nicoud / @sebnukem

02/04/2019 at 10:58PM

9
#111 - Nick Lucent / @NickLucent

02/22/2019 at 07:46AM

9
#112 - alekfed / @alek_fed

04/15/2019 at 12:00PM

9
#113 - james_bunch / @james_bunch

05/01/2019 at 05:18AM

9
#114 - ow / @ow34480012

05/01/2019 at 09:44PM

9
#115 - Grant / @grant_7788

05/02/2019 at 09:02AM

9
#116 - maximilian / @maximil61408276

05/21/2019 at 09:03PM

9
#117 - JonasS / @jonas42s

06/03/2019 at 08:29AM

9
#118 - BunFluffman / @BFluffman

06/09/2019 at 07:46PM

9
#119 - majo senf / @majo_senf

06/17/2019 at 08:40PM

9
#120 - mkaminaga / @mkmng3

07/01/2019 at 07:56AM