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
#31 - Anthony George / @Xanuthatusu

06/12/2017 at 08:03PM

9
#32 - kanazawak / @_kanazawak

06/13/2017 at 03:11PM

9
#33 - Michael Buckley / @apolatg

06/13/2017 at 09:26PM

9
#34 - xer0x / @xer0x

06/16/2017 at 05:16AM

9
#35 - Brian Hall / @_bruab_

06/16/2017 at 05:42PM

9
#36 - Sebastián Etra / @EtraStyle

06/17/2017 at 04:07AM

9
#37 - Joel Meyer-Hamme / @JoelMeyerHamme

06/18/2017 at 12:06PM

9
#38 - Super VedoVatto / @supervedovatto

06/18/2017 at 12:14PM

9
#39 - Meriadec Pillet / @loomisBroom

06/18/2017 at 05:36PM

9
#40 - Артем Верхоглядов / @artditel

06/19/2017 at 03:26PM

9
#41 - Kawin Nikomborirak / @KNikomborirak

06/21/2017 at 05:06AM

9
#42 - Christian Stammen / @c0smiq

06/21/2017 at 09:11PM

9
#43 - YamasakiKenta / @ymknjugg

06/24/2017 at 08:10AM

9
#44 - Mayank Suman / @mayank_suman

06/24/2017 at 05:28PM

9
#45 - akanb / @GAkt6L6SlKhy8zA

06/28/2017 at 03:49AM

9
#46 - Bennett Bernardoni / @BBernardoni

06/28/2017 at 04:54PM

9
#47 - 杨洋 / @176795444

07/01/2017 at 05:21AM

9
#48 - Stop and think / @ms_uncountable

07/07/2017 at 07:58PM

9
#49 - Dick Quixly / @DickQuixly

07/09/2017 at 02:24PM

9
#50 - Jon Barker / @j0nbarker

07/13/2017 at 11:24PM

9
#51 - Ryan McNamara / @MadDogMcNamara

07/16/2017 at 05:21PM

9
#52 - zhangxspace / @zhangxspace1

07/25/2017 at 09:21AM

9
#53 - Gabriel Siqueira / @gabrielhsiq

07/27/2017 at 01:24PM

9
#54 - huho / @huho_xu

07/29/2017 at 06:08PM

9
#55 - Matt / @mcr05

08/06/2017 at 09:37PM

9
#56 - Cheer / @yougec

08/11/2017 at 04:00AM

9
#57 - Jonathan Eidsness / @jonathaneidsnes

08/11/2017 at 10:39PM

9
#58 - Baine Wedlock / @BaineWedlock

08/13/2017 at 05:54PM

9
#59 - dadav 🥀 / @__dadav__

08/16/2017 at 05:47PM

9
#60 - Philippe Brouillard / @_kurowasan

08/20/2017 at 03:38AM