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
#121 - Chester Yap / @Chest_ErYap

07/22/2019 at 11:55AM

9
#122 - Miłosz Łakomy / @foobar01123

07/26/2019 at 11:49AM

9
#123 - sooqua / @sooqua

08/09/2019 at 04:48AM

9
#124 - theBecwar / @thebecwar

08/19/2019 at 05:44PM

9
#125 - Brandon Harrison / @llAboutB

09/24/2019 at 10:18PM

9
#126 - Viktor Styrud / @ViktorStyrud

10/10/2019 at 12:24PM

9
#127 - vimgolfer / @vimgolfer7

10/22/2019 at 02:01AM

9
#128 - Mario Olofo / @mario_olofo

10/23/2019 at 10:57PM

9
#129 - leo / @leo28356948

11/15/2019 at 02:13AM

9
#130 - James Casey / @hanavi

12/22/2019 at 12:20AM

9
#131 - Delon / @delonleonard

01/05/2020 at 06:38AM

9
#132 - 임덕윤 / @SnLHUF5ZYJXqI1m

01/05/2020 at 01:12PM

9
#133 - Michael Meixner / @meixner62

01/23/2020 at 06:57PM

9
#134 - vicver09 / @vicver091

01/27/2020 at 04:03AM

9
#135 - brightlyopen / @brightlyopen

02/22/2020 at 08:06PM

9
#136 - countime / @countime1

03/13/2020 at 08:43AM

9
#137 - floyd / @floyd10086

04/01/2020 at 05:10AM

9
#138 - Jason / @roosjason

05/22/2020 at 05:28AM

9
#139 - Moatvald / @moatvald

05/25/2020 at 03:21PM

9
#140 - もりを / @morio_prog

06/20/2020 at 02:55AM

9
#141 - Ming Dai / @MingDai2

07/01/2020 at 04:46PM

9
#142 - Jon Krause / @jkrause314

12/15/2020 at 04:34AM

9
#143 - hepebexè / @hepebexe

12/28/2020 at 11:24PM

9
#144 - Ray Dennis / @raysden

01/05/2021 at 10:12PM

9
#145 - Jung Yeon Park / @park_jungy

01/14/2021 at 03:30PM

9
#146 - A A A / @37fatos

01/17/2021 at 07:23PM

9
#147 - Max / @Max17868626

11/07/2021 at 12:25PM

9
#148 - Alex / @AlexanderHeatl2

05/30/2022 at 09:51PM

9
#149 - russellzhaomao / @russellzhaomao

07/01/2022 at 12:31AM

9
#150 - Daksha Chatur / @DakshaChatur

09/26/2022 at 05:40AM