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
#151 - Janzen / @__Coos

10/04/2022 at 10:46AM

9
#152 - Mrmclarrinson / @mrmclarrinson

12/14/2022 at 10:57AM

9
#153 - ky05uk3 / @kyo89347563

12/25/2022 at 12:26PM

9
#154 - moh ayaya / @AyayaMoh

09/24/2023 at 06:22PM

9
#155 - Eduardo Cassiano 🍥 / @compiledge

10/02/2023 at 12:08AM

9
#156 - MonkieeBoi / @MonkieeBoi

12/06/2023 at 06:12AM

9
#157 - Remus Dalrymple / @bornintheflames

12/23/2023 at 05:24AM

9
#158 - Ryan Kilpadi / @rkilpadi

03/03/2024 at 06:43AM

9
#159 - Peppa Pig / @PeppaPigSg

06/12/2024 at 05:21AM

9
#160 - Giacomo Sansone / @pcineverdies

07/30/2024 at 05:59PM

9
#161 - ARK / @ARezaK

08/24/2024 at 06:53PM

9
#162 - nickGPT / @nickandbro

08/28/2024 at 02:50AM

9
#163 - DayuanX / @DayuanX

10/08/2024 at 11:37AM

9
#164 - Pim / @Pireax

11/11/2024 at 12:28AM

10
#165 - Victor Ramirez / @virako

05/31/2017 at 09:05PM

10
#166 - martin tourneboeuf / @martintournebo1

06/01/2017 at 05:47PM

10
#167 - Sergey Lisakov / @pozitron57

06/06/2017 at 08:19PM

10
#168 - Harsh Kumar / @datsleepyguy

06/07/2017 at 05:58PM

10
#169 - Benoit Benoit / @Benoit_Tgt

06/08/2017 at 04:49PM

10
#170 - Carl Egbert / @CarlOEgbert

06/09/2017 at 05:51AM

10
#171 - Robert Mosher / @rcmosher

06/15/2017 at 05:26PM

10
#172 - John Smith / @john828495

06/16/2017 at 02:01PM

10
#173 - John Smith / @johns32768

06/16/2017 at 06:46PM

10
#174 - Tom Sisk / @TomSisk

06/21/2017 at 12:43AM

10
#175 - Kieron Browne / @KieronBrowne1

06/30/2017 at 08:04AM

10
#176 - Ben Hill / @KaizenSoze70

06/30/2017 at 12:40PM

10
#177 - Pfhor / @PfhorShark

07/02/2017 at 02:53PM

10
#178 - Scott Mills / @smm1729

07/11/2017 at 03:31AM

10
#179 - Jacob Buete / @JBuete

07/20/2017 at 12:14PM

10
#180 - adeel hussain / @adeelhussain

07/31/2017 at 06:15AM