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):
10
#211 - Ryan Nevius / @ryannevius

03/27/2020 at 05:31PM

10
#212 - iBhagwan / @iiBhagwan

05/16/2020 at 03:12AM

10
#213 - roudens / @roudens2

01/18/2021 at 12:15AM

10
#214 - Michel Viktor / @tomkpz

08/12/2021 at 02:01AM

10
#215 - Jean George / @JeanGeo20504212

10/01/2021 at 08:32AM

10
#216 - Brandon / @Brandon10678836

08/26/2022 at 12:59PM

10
#217 - vladanscy / @vladanscy

02/20/2023 at 08:18PM

10
#218 - Luoyb / @Luoyb

11/17/2023 at 02:37AM

10
#219 - Prem Netsuwan / @grnnja

08/27/2024 at 03:43PM

10
#220 - Nathan Priego / @nspriego

03/01/2025 at 04:54AM

11
#221 - tPenguinLTG / @tpenguinltg

05/25/2017 at 04:41AM

11
#222 - Anoop Kumar / @anooplive

05/25/2017 at 04:53AM

11
#223 - Benedikt Ames / @wisp3rwind

06/01/2017 at 03:17PM

11
#224 - Laurent Atlan / @laurentatlan1

09/10/2017 at 07:00PM

11
#225 - niwatoco / @yoshitune9

07/19/2018 at 07:48PM

11
#226 - Timothy Bryan / @tim_bryan

02/22/2019 at 11:45PM

11
#227 - Hans Lidiki / @HLidiki

09/07/2019 at 06:18PM

11
#228 - RockerZZY / @rocker_zzy

06/03/2020 at 02:11AM

11
#229 - Put me on your list tyrants / @electronjunkie

08/16/2020 at 07:01PM

11
#230 - jonas-grobe / @jonas-grobe

02/03/2024 at 08:36PM

12
#231 - AleksandarTrifunovic / @akstrfn

05/25/2017 at 03:46PM

12
#232 - Cristian / @cris_perez_b

05/26/2017 at 08:29AM

12
#233 - squid / @zerosquid

05/26/2017 at 11:50PM

12
#234 - jakeroberts / @jakeroberts

05/27/2017 at 07:31PM

12
#235 - duke of garda / @dukeofgarda

05/29/2017 at 07:32PM

12
#236 - Edouard Piette / @EdPiette

05/30/2017 at 11:41AM

12
#237 - James / @Dronak

05/31/2017 at 01:15AM

12
#238 - Davis Fields / @i301585

06/09/2017 at 04:37AM

12
#239 - Ayman Farhat / @aymanfarhat

06/11/2017 at 11:28AM

12
#240 - jsg / @jsg1122

06/13/2017 at 12:31AM