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 [challenge ID]

Played Challenges

Simple, Practical, and Common - 33617 entries

Simple things we do all the time should be able to be done with very few keystrokes, but sometimes I find something I need to do makes me go, "There MUST be a better way." This challenge is just a simple movement and entering text at a certain place.

  • Best score: 22
  • Best player score: 22
  • Position: #6 / 7421
  • Number of attempts: 6
Swap values - 4616 entries

Well, swap the values...

  • Best score: 11
  • Best player score: 12
  • Position: #372 / 1268
  • Number of attempts: 7
One number per line - 18727 entries

Just give me the numbers.

  • Best score: 14
  • Best player score: 14
  • Position: #258 / 3864
  • Number of attempts: 9
Separate the lines - 182 entries

Every other line is mixed up. Separate them into their original texts.

  • Best score: 11
  • Best player score: 14
  • Position: #77 / 92
  • Number of attempts: 1
Swap values inside brackets - 2496 entries

Easy challenge.

  • Best score: 14
  • Best player score: 16
  • Position: #222 / 579
  • Number of attempts: 6
V to the i - 4802 entries

Input is 99 V's. Output is 100 i's.

  • Best score: 7
  • Best player score: 7
  • Position: #196 / 1893
  • Number of attempts: 3
Split line with dots - 2144 entries

This line is too long, split it.

  • Best score: 15
  • Best player score: 15
  • Position: #29 / 634
  • Number of attempts: 4
remove lines containing the word "reader" - 3586 entries

easy stuff

  • Best score: 9
  • Best player score: 10
  • Position: #513 / 1162
  • Number of attempts: 5
Copy three lines - 2872 entries

If the site is up (by some miracle), make the text under every header identical.

  • Best score: 13
  • Best player score: 18
  • Position: #302 / 640
  • Number of attempts: 4
Search and Replace 0 - 4989 entries

Replace every instance of 'aaa' with 'xaaax'.

  • Best score: 12
  • Best player score: 13
  • Position: #832 / 1624
  • Number of attempts: 3
That hyphen - 2595 entries

"vim vi improved"

  • Best score: 9
  • Best player score: 9
  • Position: #63 / 701
  • Number of attempts: 7
comment and uncomment code inline - 1122 entries

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.

  • Best score: 9
  • Best player score: 9
  • Position: #11 / 322
  • Number of attempts: 4
Just the middle - 11454 entries

Delete the instructions at the top and bottom.

  • Best score: 7
  • Best player score: 7
  • Position: #234 / 4197
  • Number of attempts: 6
Make HTML List - 1050 entries

Turn the comma separated list into an unordered html list.

  • Best score: 33
  • Best player score: 41
  • Position: #97 / 273
  • Number of attempts: 2
For all cases. - 161 entries

In this case... change it! :) Watch the line.

  • Best score: 8
  • Best player score: 8
  • Position: #19 / 106
  • Number of attempts: 2
Stairstep digits - 394 entries

Remove the evens. Double the odds.

  • Best score: 9
  • Best player score: 13
  • Position: #62 / 145
  • Number of attempts: 3
Turn a ninja to case-insensitive [Nn][Ii][Nn][Jj][Aa] regexp! - 67 entries

I bumped into this in a dailywtf code: http://pastebin.com/QApa5ycS I didn't want to translate a string whenever I wanted to be [Ss][Aa][Rr][Cc][Aa][Ss][Tt][Ii][Cc] on slack, so I figured a script (python, sed, whatever) would be helpful. Well, or a few vim keystroke!

  • Best score: 18
  • Best player score: 20
  • Position: #38 / 39
  • Number of attempts: 2
Basic renumbering - 5648 entries

Renumbering Basic.

  • Best score: 11
  • Best player score: 14
  • Position: #373 / 1264
  • Number of attempts: 5
Adam's challenge - 984 entries

Change both normal to bold and 4 by 2. Adam Wathan challenge this on twitter . He did it in 11 keystrokes on Sublime.

  • Best score: 18
  • Best player score: 19
  • Position: #103 / 270
  • Number of attempts: 5
replace 2nd column blanks with values in same column if blank - 242 entries

Where ,SOMELOGB and ,SOMELOGC replaces each /r carriage return if 2nd column is blank. The replace only happens if 2nd column is blank though and should replace up to the non blank row.

  • Best score: 15
  • Best player score: 15
  • Position: #17 / 83
  • Number of attempts: 4
Wrap text in quotes - 368 entries

All the blocks of text should be wrapped in quotation marks.

  • Best score: 16
  • Best player score: 16
  • Position: #11 / 122
  • Number of attempts: 4
underscore_to_camelCase - 173 entries

Pointy haired boss decided we need to switch to camelCase. Let's get this over with.

  • Best score: 14
  • Best player score: 21
  • Position: #70 / 82
  • Number of attempts: 2
Vice versa - 7907 entries

Little role switching.

  • Best score: 12
  • Best player score: 15
  • Position: #980 / 2128
  • Number of attempts: 1
Sort files from hosts - 188 entries

Resume files by host. I hope you enjoy with this challenge

  • Best score: 15
  • Best player score: 18
  • Position: #51 / 76
  • Number of attempts: 1
Inner hyphens - 136 entries

Yet another hyphen challenge. Adding 5 hyphens to a file shouldn't be too hard.

  • Best score: 11
  • Best player score: 12
  • Position: #19 / 82
  • Number of attempts: 1
Change attribute to getter - 140 entries

Wrap attributes with a getter method.

  • Best score: 24
  • Best player score: 25
  • Position: #37 / 59
  • Number of attempts: 2
Alsa configuration - 513 entries

I'm tweaking my ~/.asoundrc file!

  • Best score: 22
  • Best player score: 26
  • Position: #72 / 128
  • Number of attempts: 5
Align commas - 1095 entries

There are 15,000 aligning challenges on vimgolf.com, and they're all exactly the same. I hope this one is a little different.

  • Best score: 11
  • Best player score: 17
  • Position: #147 / 246
  • Number of attempts: 1
Change part of a function name in multiple occurrences - 662 entries

Change the middle part of the function name in multiple places, preferably using the next and dot commands.

  • Best score: 14
  • Best player score: 15
  • Position: #74 / 208
  • Number of attempts: 2
Delete to the end of the current line - 812 entries

Delete to the end of the current line, but keep the character under the cursor.

  • Best score: 5
  • Best player score: 6
  • Position: #288 / 391
  • Number of attempts: 4
Mirror Symmetry - 822 entries

Add backslashes.

  • Best score: 7
  • Best player score: 7
  • Position: #3 / 269
  • Number of attempts: 6
Entries sort - 90 entries

It cames to my mind a weird idea : sorting parts of my .vimrc. Take few minutes to sort out this, it's easy !

  • Best score: 14
  • Best player score: 14
  • Position: #10 / 40
  • Number of attempts: 8
Collect List - 4298 entries

Convert to comma separated list.

  • Best score: 12
  • Best player score: 12
  • Position: #13 / 1190
  • Number of attempts: 5
camel riding - 793 entries

add a prefix on some camelCase variables

  • Best score: 15
  • Best player score: 15
  • Position: #14 / 281
  • Number of attempts: 4
swap or reverse - 126 entries

Try to swap or reverse the line as needed.

  • Best score: 16
  • Best player score: 19
  • Position: #64 / 69
  • Number of attempts: 1
readability - 327 entries

Make the code readable by adding some spaces

  • Best score: 18
  • Best player score: 19
  • Position: #83 / 152
  • Number of attempts: 1
Logging with key - 328 entries

Sometimes it is better to log with meaningful key

  • Best score: 21
  • Best player score: 21
  • Position: #13 / 88
  • Number of attempts: 7
Space out the alphabet - 1657 entries

Put 3 spaces between adjacent letters.

  • Best score: 15
  • Best player score: 15
  • Position: #25 / 444
  • Number of attempts: 4
remove all lines in first part - 211 entries

From the second part, remove all lines in the first part. It can be useful when you have done something from a long list, you want to know what is not done yet!

  • Best score: 13
  • Best player score: 16
  • Position: #36 / 67
  • Number of attempts: 6
Fix the XML - 1039 entries

The challenge consists in having a valid xml from an incomplete source.

  • Best score: 18
  • Best player score: 21
  • Position: #87 / 290
  • Number of attempts: 3
Shuffled numbers - 246 entries

Each number is paired with the number it should follow. That's enough information to put them in order.

  • Best score: 15
  • Best player score: 15
  • Position: #4 / 96
  • Number of attempts: 4
Mute the second method of this script - 455 entries

prepend a # infront of every line of the second method

  • Best score: 8
  • Best player score: 9
  • Position: #75 / 239
  • Number of attempts: 4
Condensed Cases - 804 entries

Apple's new programming language, Swift, allows two style of case statements: 1) one Enum case on each line, or 2) multiple Enum cases on a single line. Convert the following from the first case (no pun intended) to the second type.

  • Best score: 12
  • Best player score: 13
  • Position: #81 / 247
  • Number of attempts: 3
Happy TvvO - 427 entries

Don’t forget the past, learn from it. Happy New Year.

  • Best score: 12
  • Best player score: 12
  • Position: #91 / 206
  • Number of attempts: 3
I forgot quotes - 15983 entries

Oops.

  • Best score: 10
  • Best player score: 10
  • Position: #156 / 4180
  • Number of attempts: 6
-a-b-c- - 3213 entries

Put hyphens everywhere.

  • Best score: 13
  • Best player score: 13
  • Position: #89 / 1137
  • Number of attempts: 3
Count both ways - 1022 entries

Right AND down.

  • Best score: 13
  • Best player score: 15
  • Position: #107 / 354
  • Number of attempts: 3
Suffix sort - 270 entries

Sort from the end of the line, as if the letters in each line were reversed.

  • Best score: 19
  • Best player score: 31
  • Position: #61 / 67
  • Number of attempts: 1
Gray area - 747 entries

It's a golf metaphor or something.

  • Best score: 11
  • Best player score: 12
  • Position: #74 / 271
  • Number of attempts: 4
Do you demand a shrubbery? - 1158 entries

Use :redir and crush the emacsgolfers.

  • Best score: 15
  • Best player score: 20
  • Position: #170 / 300
  • Number of attempts: 1
Don't know what this is - 2022 entries

Replace contents of brackets with matching number of spaces. Don't ask what the format's supposed to be.

  • Best score: 11
  • Best player score: 16
  • Position: #488 / 585
  • Number of attempts: 4
Where should I put the Newline? - 881 entries

Help me put the newline.

  • Best score: 7
  • Best player score: 8
  • Position: #351 / 437
  • Number of attempts: 1
A HAPPY NEW YEAR 2014 ! - 10663 entries

A HAPPY NEW YEAR 2014 !

  • Best score: 11
  • Best player score: 11
  • Position: #692 / 3683
  • Number of attempts: 5
Words in parens - 12935 entries

We should all ace this, right?

  • Best score: 13
  • Best player score: 14
  • Position: #538 / 3963
  • Number of attempts: 4
SFD-ROC: vimvimvim - 1606 entries

Oh no, this line is longer than 80 chars... put each 'vim' on a new line.

  • Best score: 8
  • Best player score: 8
  • Position: #76 / 446
  • Number of attempts: 5
Saving the hashes(#) - 2063 entries

The following file is copied from vimcasts.org(Its only for learning purpose,hope the site owner doesn't mind it), its probably the easiest of challenges.Our goal is to delete every line which doesn't contain a hash signs. The remaining hash signs with numbers are then sorted to get the final output.

  • Best score: 20
  • Best player score: 29
  • Position: #341 / 480
  • Number of attempts: 2
Vertical Limit - 2538 entries

transform a succession of one word lines to a an array of strings

  • Best score: 21
  • Best player score: 24
  • Position: #293 / 754
  • Number of attempts: 2
replacing each line of a block selection - 2999 entries

replace each line's ../assets/js with /javascripts

  • Best score: 18
  • Best player score: 19
  • Position: #181 / 777
  • Number of attempts: 4
switch variable - 5071 entries

how fast can you switch two variable ?

  • Best score: 11
  • Best player score: 11
  • Position: #353 / 1748
  • Number of attempts: 6
imports alignment (python) - 700 entries

Align as one import per line.

  • Best score: 17
  • Best player score: 27
  • Position: #140 / 198
  • Number of attempts: 2
The Cake is a Lie - 1346 entries

Correct the capitalization of each word

  • Best score: 9
  • Best player score: 9
  • Position: #203 / 527
  • Number of attempts: 2
Change the content of a string - 1580 entries

This docstring is a complete lie. Fix it.

  • Best score: 22
  • Best player score: 22
  • Position: #161 / 588
  • Number of attempts: 3
Whitespace, empty lines and tabs - 3665 entries

Convert tabs to spaces, strip empty lines and trailing whitespace.

  • Best score: 16
  • Best player score: 28
  • Position: #480 / 787
  • Number of attempts: 4
Simple text editing with Vim - 12811 entries

Make the pairs of lines match up by making each second line same as first

  • Best score: 13
  • Best player score: 14
  • Position: #1430 / 3694
  • Number of attempts: 2

Contributed Challenges

Pretty multi-line bash - 235 entries

Bash line continuations are much prettier when they're column aligned.

underscore_to_camelCase - 173 entries

Pointy haired boss decided we need to switch to camelCase. Let's get this over with.

we’re going to need a bigger bot
Twitter:

programmer, cloud, serverless, vim. my other accounts: @assafketo (nutrition, science), @assafheb (Hebrew)

entered into 64 challenges

contributed 2 challenges