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

vim = 22 / 7 - 447 entries

pi square vim

  • Best score: 20
  • Best player score: 20
  • Position: #19 / 131
  • Number of attempts: 13
Wrap the text of an email message to 79 characters - 652 entries

You're replying to an email with silly long lines. Clean them up.

  • Best score: 5
  • Best player score: 5
  • Position: #160 / 376
  • Number of attempts: 1
Extract argument from function - 2283 entries

The aim is to see if you can do some refactoring very fast.

  • Best score: 13
  • Best player score: 13
  • Position: #2 / 739
  • Number of attempts: 6
Search and Replace 0 - 4766 entries

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

  • Best score: 12
  • Best player score: 12
  • Position: #190 / 1578
  • Number of attempts: 6
Just the middle - 11318 entries

Delete the instructions at the top and bottom.

  • Best score: 7
  • Best player score: 7
  • Position: #139 / 4152
  • Number of attempts: 4
Python Hello World! Reformatting - 930 entries

A novice Python using prints Hello World! and a pro shows him different way. Using vim to get into pro style from novice, win the challenge.

  • Best score: 39
  • Best player score: 43
  • Position: #154 / 361
  • Number of attempts: 1
Create Leading Zeros - 208 entries

Create leading zeros only for id columns. Please use generic approach!

  • Best score: 23
  • Best player score: 23
  • Position: #5 / 78
  • Number of attempts: 6
O Christmas Tree - 102 entries

Design a macro that makes trees grow (or ASCII triangles, if that's too hard).

  • Best score: 22
  • Best player score: 31
  • Position: #31 / 41
  • Number of attempts: 2
Swap assigned value - 593 entries

Simple problem but looking for interesting solutions.

  • Best score: 10
  • Best player score: 10
  • Position: #58 / 242
  • Number of attempts: 6
Change your calendar - 352 entries

Happy New Year!

  • Best score: 18
  • Best player score: 46
  • Position: #80 / 83
  • Number of attempts: 3
VimGolfNight - 524 entries

Based on "The name of the game".

  • Best score: 12
  • Best player score: 12
  • Position: #6 / 339
  • Number of attempts: 3
camel riding - 765 entries

add a prefix on some camelCase variables

  • Best score: 15
  • Best player score: 18
  • Position: #195 / 273
  • Number of attempts: 1
readability - 310 entries

Make the code readable by adding some spaces

  • Best score: 18
  • Best player score: 24
  • Position: #142 / 147
  • Number of attempts: 6
Logging with key - 301 entries

Sometimes it is better to log with meaningful key

  • Best score: 21
  • Best player score: 21
  • Position: #11 / 86
  • Number of attempts: 13
Space out the alphabet - 1610 entries

Put 3 spaces between adjacent letters.

  • Best score: 15
  • Best player score: 15
  • Position: #5 / 438
  • Number of attempts: 8
Not enough Ps - 66 entries

Different type of code

  • Best score: 13
  • Best player score: 13
  • Position: #11 / 35
  • Number of attempts: 2
Fix the XML - 962 entries

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

  • Best score: 18
  • Best player score: 18
  • Position: #13 / 280
  • Number of attempts: 7
Mute the second method of this script - 447 entries

prepend a # infront of every line of the second method

  • Best score: 9
  • Best player score: 9
  • Position: #34 / 237
  • Number of attempts: 8
Sorting database text output - 213 entries

Sometimes it is nice to be able to quickly take column-formatted text output from the SQL command line and turn it into a list of useful data. In this case we want a unique, sorted list of the values from the second column combined into one comma-separated list. What is the fewest strokes you can do this in?

  • Best score: 24
  • Best player score: 24
  • Position: #15 / 80
  • Number of attempts: 6
Happy TvvO - 396 entries

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

  • Best score: 12
  • Best player score: 12
  • Position: #67 / 197
  • Number of attempts: 4
I forgot quotes - 15880 entries

Oops.

  • Best score: 10
  • Best player score: 10
  • Position: #98 / 4146
  • Number of attempts: 6
-a-b-c- - 3160 entries

Put hyphens everywhere.

  • Best score: 13
  • Best player score: 13
  • Position: #72 / 1124
  • Number of attempts: 4
NBCU Weekly Challenge - Test - 243 entries

Just testing.

  • Best score: 18
  • Best player score: 20
  • Position: #76 / 114
  • Number of attempts: 2
Change name of a variable - 169 entries

Replace the name of the $variable with the fastest move possible. The challenge is having a command that allow you to easily change the variable name even if its indented.

  • Best score: 9
  • Best player score: 9
  • Position: #21 / 132
  • Number of attempts: 1
Neither Fizz nor Buzz - 226 entries

Not your regular increment macro! The gaps are tricky.

  • Best score: 13
  • Best player score: 20
  • Position: #49 / 99
  • Number of attempts: 4
Don't know what this is - 1961 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: 11
  • Position: #4 / 576
  • Number of attempts: 9
Mess in revision history - 1157 entries

Help Joe clean up what Steve has cobbled.

  • Best score: 17
  • Best player score: 18
  • Position: #78 / 245
  • Number of attempts: 13
Shuffle puzzle - 317 entries

Sort the lines in each indent group, and sort the groups. That's the pattern. Or just move lines around manually to get a better score.

  • Best score: 13
  • Best player score: 13
  • Position: #7 / 101
  • Number of attempts: 10
Going underground.... - 315 entries

Simple reformatting: in this case changing from the format London underground supplies its customers with, to the format that Google Calendar likes...

  • Best score: 22
  • Best player score: 28
  • Position: #32 / 122
  • Number of attempts: 1
Split the words - 356 entries

Add the spaces manually if you must, but if you use Vim's spell checking feature wisely, I think you'll save a LARGE number of strokes.

  • Best score: 18
  • Best player score: 42
  • Position: #92 / 108
  • Number of attempts: 3
A HAPPY NEW YEAR 2014 ! - 10584 entries

A HAPPY NEW YEAR 2014 !

  • Best score: 11
  • Best player score: 12
  • Position: #1610 / 3653
  • Number of attempts: 4
attr_aligner - 3408 entries

Two attr keywords. Two separate indentations. Align the colons.

  • Best score: 19
  • Best player score: 34
  • Position: #533 / 689
  • Number of attempts: 2
Ninjas Leaderboard - 84 entries

The two lines in "Start file" has an obfuscated email address. Second line give an index (from 1 to 30) to the chars list of the first line, for example, the first char of email (n) is in position 25, second char (i) is in position 19 and s.o.

  • Best score: 25
  • Best player score: 35
  • Position: #27 / 38
  • Number of attempts: 1
Counting in binary - 447 entries

"a" represents 0; "A" represents 1. Start from zero and count to 15.

  • Best score: 16
  • Best player score: 38
  • Position: #68 / 112
  • Number of attempts: 5
Letter case trickery - 1588 entries

This file is in a downright esoteric format, consisting of hexadecimal numbers, non-hexadecimal keywords, and "Z" indicating end-of-line. Make the hexadecimal numbers lowercase.

  • Best score: 9
  • Best player score: 11
  • Position: #187 / 509
  • Number of attempts: 4
quotes inside quotes - 3105 entries

taken from tip 85 of the very good book 'Practical Vim: Edit Text at the Speed of Thought' ! I'd be interested what people use :)

  • Best score: 14
  • Best player score: 15
  • Position: #396 / 1066
  • Number of attempts: 5
Sort the VimGolf challenges by popularity - 344 entries

"Sort by popularity" is a good order to play the challenges. Not perfect, but you could do a lot worse. ;) Input is a sample copy-pasted from vimgolf.com. Some of the challenge names have digits that will get in your way, so read ":help :sort" for hints on sorting with a regex. When you're done, try your solution on the full list!

  • Best score: 15
  • Best player score: 15
  • Position: #17 / 104
  • Number of attempts: 8
Words in parens - 12821 entries

We should all ace this, right?

  • Best score: 13
  • Best player score: 14
  • Position: #213 / 3938
  • Number of attempts: 7
Hole-in-one - 1012 entries

Lets take this golf thing literally.. Drive off the tee into the hole, and of course you don't strike the ball completely clean.

  • Best score: 15
  • Best player score: 21
  • Position: #209 / 302
  • Number of attempts: 7
Delete unwanted lines - 392 entries

Delete all lines which does not end in "o.."

  • Best score: 9
  • Best player score: 9
  • Position: #109 / 224
  • Number of attempts: 2
Minimalist Limerick - 514 entries

Reproduce this lovely poem.

  • Best score: 31
  • Best player score: 34
  • Position: #54 / 170
  • Number of attempts: 8
XML to JSON - 44 entries

Convert this xml file into json.

  • Best score: 75
  • Best player score: 141
  • Position: #9 / 17
  • Number of attempts: 4
Coordinates placeholder - 62 entries

Place coordinates instead of target search.

  • Best score: 22
  • Best player score: 26
  • Position: #28 / 36
  • Number of attempts: 1
Define to require - 118 entries

When JSHint is enabled, there's a rule that doesn't let you have more than 6 arguments in a function, so the moment you need to add a 7th argument, you need to do a refactoring.

  • Best score: 62
  • Best player score: 79
  • Position: #23 / 48
  • Number of attempts: 2
Enumerate words - 242 entries

Enumerate the unique words in order.

  • Best score: 23
  • Best player score: 26
  • Position: #40 / 87
  • Number of attempts: 5
Execute immediate SQL - 85 entries

Sql string tranformation ...

  • Best score: 60
  • Best player score: 70
  • Position: #10 / 30
  • Number of attempts: 4
Circle in a square - 140 entries

Probably looks more like "Egg in a rectangle" in most fonts, but it's actually 23x23.

  • Best score: 23
  • Best player score: 69
  • Position: #40 / 52
  • Number of attempts: 3
Groups magic - 146 entries

Regexp or macros for string converting: (a) -> ___ (abc) -> ____ (abcd) -> ______ All in the '(' replace to _ multiply by char count + ()

  • Best score: 13
  • Best player score: 14
  • Position: #30 / 88
  • Number of attempts: 4
Prefixes and suffixes - 590 entries

Generate all prefixes of "vimchallenge", then all suffixes.

  • Best score: 17
  • Best player score: 23
  • Position: #46 / 191
  • Number of attempts: 5
abcd > a b c d - 279 entries

transform the single spaces into 4 spaces repeat for each line

  • Best score: 15
  • Best player score: 15
  • Position: #70 / 217
  • Number of attempts: 1
Python: Lots of function arguments - 98 entries

The function definition is too long for one line. The modeline helps you with some typical Python indent settings.

  • Best score: 13
  • Best player score: 16
  • Position: #34 / 44
  • Number of attempts: 3
Dehamlizing - 177 entries

Change this piece of HAML code back into erb

  • Best score: 32
  • Best player score: 42
  • Position: #42 / 68
  • Number of attempts: 5
NATO phonetic alphabet - 498 entries

Transform the series of words into a list.

  • Best score: 19
  • Best player score: 21
  • Position: #79 / 189
  • Number of attempts: 2
Create a pandoc compatible table - 177 entries

In [this vimcast][1], a featured gist from Tim Pope shows how to quickly make a simple table structure. How fast can you convert it to pandoc's markdown style? [1]: http://vimcasts.org/episodes/aligning-text-with-tabular-vim/

  • Best score: 32
  • Best player score: 50
  • Position: #38 / 51
  • Number of attempts: 4
A simple change - 434 entries

Just change the numbers in the most efficient way ...

  • Best score: 12
  • Best player score: 12
  • Position: #17 / 187
  • Number of attempts: 5
SFD-ROC: Tic-Tac-Toe - 132 entries

Tic-Tac-Toe You are 'X', and it is your turn. Stop 'O' from winning, and complete the game. Draw a diagonal line through your winning row of three X's.

  • Best score: 25
  • Best player score: 35
  • Position: #31 / 50
  • Number of attempts: 5
Extract text from xml - 106 entries

Extract text from xml file (ignoring commented out elements) and create a one line regex.

  • Best score: 28
  • Best player score: 35
  • Position: #16 / 43
  • Number of attempts: 3
The Quick Brown Fox Jumps Over The Lazy Vim - 398 entries

Someone has vandalized this text file and replaced the beginning character of one word in each line with a Big "X." Please remove the big X's, and fix each line to read "The Quick Brown Fox Jumps Over The Lazy Dog."

  • Best score: 8
  • Best player score: 10
  • Position: #64 / 186
  • Number of attempts: 2
The name of the game - 643 entries

End up with the name of the game.

  • Best score: 11
  • Best player score: 11
  • Position: #83 / 353
  • Number of attempts: 2
lamb had a little Mary - 570 entries

"Mary" and "lamb" are swapped. Unswap them. Fast as you can.

  • Best score: 16
  • Best player score: 16
  • Position: #4 / 160
  • Number of attempts: 7
SFD-ROC: vimvimvim - 1550 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: #18 / 435
  • Number of attempts: 11
Stairs Indenting - 442 entries

Indent each line with <line number> whitespaces.

  • Best score: 12
  • Best player score: 12
  • Position: #7 / 191
  • Number of attempts: 8
Python to Ruby - 193 entries

Convert this Python code to Ruby. NOTE: This program likely won't run.

  • Best score: 24
  • Best player score: 27
  • Position: #24 / 57
  • Number of attempts: 8
Saving the hashes(#) - 1977 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: 21
  • Position: #87 / 470
  • Number of attempts: 7
Convert pandoc unordered list to a numbered list - 157 entries

I know it's possible to use #. in pandoc to auto-generate numbered lists, but then it's not easy to tell how many items there are when reading it in Markdown. How fast can you make the switch?

  • Best score: 20
  • Best player score: 43
  • Position: #46 / 55
  • Number of attempts: 5
Let's play some Ivmgolf - 1066 entries

Oops, I spelled that wrong.

  • Best score: 7
  • Best player score: 7
  • Position: #53 / 436
  • Number of attempts: 6
you're stuck on jQuery < 1.7 - 335 entries

replace calls to jQuery 1.7+'s `on` with calls to pre 1.7 `bind`

  • Best score: 25
  • Best player score: 25
  • Position: #10 / 110
  • Number of attempts: 8
Vertical Limit - 2399 entries

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

  • Best score: 21
  • Best player score: 23
  • Position: #200 / 727
  • Number of attempts: 8
Exchanging Quotes - 801 entries

Sometimes you need to exchange a choice of quotes in some code.

  • Best score: 30
  • Best player score: 35
  • Position: #93 / 221
  • Number of attempts: 5
replacing each line of a block selection - 2901 entries

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

  • Best score: 18
  • Best player score: 20
  • Position: #238 / 759
  • Number of attempts: 6
Switch function arguments - 2019 entries

How to switch two arguments of a function.

  • Best score: 11
  • Best player score: 11
  • Position: #51 / 637
  • Number of attempts: 5
Append semicolon after expressions - 986 entries

Some lines need the semicolon, some don't.

  • Best score: 11
  • Best player score: 11
  • Position: #36 / 397
  • Number of attempts: 4
Reverse and double space - 475 entries

Reverse the order of the given lines and double space everything

  • Best score: 14
  • Best player score: 14
  • Position: #41 / 191
  • Number of attempts: 6
Remove noise from HTTP log - 675 entries

This piece of log (from the year 2000) contains some irrelevant data. We only want to see the HTTP method and resource.

  • Best score: 15
  • Best player score: 15
  • Position: #56 / 266
  • Number of attempts: 3
Remove semicolons after expressions - 602 entries

A follow-up for http://vimgolf.com/challenges/4fc9d767d3a0d4000100000e.

  • Best score: 6
  • Best player score: 6
  • Position: #48 / 253
  • Number of attempts: 3
The meaning - 543 entries

Numbers are fun!

  • Best score: 5
  • Best player score: 5
  • Position: #167 / 350
  • Number of attempts: 3
Calculate the table totals - 129 entries

Go ahead... commit the treachery of using vim as a spreadsheet.

  • Best score: 33
  • Best player score: 65
  • Position: #30 / 42
  • Number of attempts: 1
Replacing some words - 418 entries

How fast could it be?

  • Best score: 17
  • Best player score: 20
  • Position: #61 / 147
  • Number of attempts: 4
PHP <--> Java class conversion Part 1 - 211 entries

Convert this tiny php class to adequate java one.

  • Best score: 65
  • Best player score: 84
  • Position: #20 / 61
  • Number of attempts: 4
Sort the cardinal numbers - 284 entries

Maybe a simple challenge.

  • Best score: 12
  • Best player score: 46
  • Position: #139 / 143
  • Number of attempts: 3
Make it more readable - 1930 entries

Insert blank lines to make it more organized and readable

  • Best score: 13
  • Best player score: 14
  • Position: #143 / 636
  • Number of attempts: 5
remove dupes from array - 1324 entries

given a random string that contains a ruby-esque array, make sure that there are no duplicate elements

  • Best score: 17
  • Best player score: 21
  • Position: #145 / 328
  • Number of attempts: 6
imports alignment (python) - 657 entries

Align as one import per line.

  • Best score: 17
  • Best player score: 19
  • Position: #62 / 194
  • Number of attempts: 9
expand a list comprehension (python) - 296 entries

Please show your way to convert a list comprehension in python to an ordinary for-loop expression!

  • Best score: 42
  • Best player score: 50
  • Position: #39 / 105
  • Number of attempts: 4
Insert a Markdown link - 422 entries

Put a link in a markdown document, using the after-the-paragraph format.

  • Best score: 22
  • Best player score: 24
  • Position: #60 / 142
  • Number of attempts: 10
Numbering a List - 1849 entries

Pretty simple, number the list.

  • Best score: 13
  • Best player score: 18
  • Position: #110 / 636
  • Number of attempts: 7
Java Array2List - 218 entries

Convert an java array initializer into a list.

  • Best score: 67
  • Best player score: 112
  • Position: #54 / 82
  • Number of attempts: 3
Assignment Alignment - 824 entries

line up the operators. Use spaces, not tabs.

  • Best score: 18
  • Best player score: 20
  • Position: #83 / 215
  • Number of attempts: 5
Shebangs for all - 1846 entries

We've all seen or used a shebang once or twice. Ditch the specific paths and leave just a dynamic Ruby and Python bath behind.

  • Best score: 11
  • Best player score: 11
  • Position: #16 / 486
  • Number of attempts: 10
A Simple One - 978 entries

Here is a very simple one - just to illustrate/introduce a vim feature that some people seem to miss...

  • Best score: 9
  • Best player score: 9
  • Position: #306 / 636
  • Number of attempts: 1
Table Reshuffle - 366 entries

Fix the column order in this table... also append the new 'username' column.

  • Best score: 22
  • Best player score: 24
  • Position: #34 / 132
  • Number of attempts: 6
Another Mixed-Up Haiku - 236 entries

VimGolf ... a perfect evening?

  • Best score: 21
  • Best player score: 21
  • Position: #28 / 85
  • Number of attempts: 3
Ruby 1.9 compat - 608 entries

Remember when Ruby supported `when <expr> :`? Well, it doesn't in 1.9, so let's make sure we use `then`, without ruining our lovely new hash syntax!

  • Best score: 14
  • Best player score: 16
  • Position: #132 / 229
  • Number of attempts: 3
Increment, increment, increment.... - 626 entries

Vim likes macros

  • Best score: 10
  • Best player score: 12
  • Position: #237 / 393
  • Number of attempts: 2
Sorting paragraphs - 502 entries

Order the paragraphs correctly, per prefixed index

  • Best score: 18
  • Best player score: 27
  • Position: #64 / 155
  • Number of attempts: 8
Indentation - 492 entries

Indent each line according to the right number of spaces it needs.

  • Best score: 21
  • Best player score: 24
  • Position: #41 / 167
  • Number of attempts: 6
Hatsuyume - 442 entries

http://en.wikipedia.org/wiki/Hatsuyume

  • Best score: 16
  • Best player score: 31
  • Position: #127 / 173
  • Number of attempts: 2
The Cake is a Lie - 1266 entries

Correct the capitalization of each word

  • Best score: 9
  • Best player score: 9
  • Position: #135 / 506
  • Number of attempts: 7
Fix the Haiku - 272 entries

Change this slightly scrambled haiku to its unscrambled form and fix the capitalisation and punctuation along the way.

  • Best score: 28
  • Best player score: 40
  • Position: #55 / 108
  • Number of attempts: 3
Context insensitive completion 0 - 493 entries

Buried in the lines you're not supposed to add is the line "Add this line!" Add that line to the top of the file.

  • Best score: 6
  • Best player score: 7
  • Position: #76 / 230
  • Number of attempts: 3
Context Insensitive completion 1 - 444 entries

Finish writing this simple Python HTTP server.

  • Best score: 18
  • Best player score: 18
  • Position: #97 / 228
  • Number of attempts: 1
Almost encrypted - 196 entries

Convert the first paragraph to be even less readable.

  • Best score: 5
  • Best player score: 5
  • Position: #101 / 144
  • Number of attempts: 1
Make Fancy Header - 996 entries

Make the header text stand out with surrounding asterisks

  • Best score: 16
  • Best player score: 16
  • Position: #78 / 335
  • Number of attempts: 5
Reformat a C golf submission - 547 entries

Take this C golf submission (for the "tiny but standards-compliant Hello World program" category, naturally), and turn it into formatted C code.

  • Best score: 22
  • Best player score: 25
  • Position: #15 / 198
  • Number of attempts: 9
Reverse characters in a line - 701 entries

You have everything you need, just not in the right order. Mastermind would give you 26 white pegs.

  • Best score: 12
  • Best player score: 15
  • Position: #125 / 248
  • Number of attempts: 3
Reformat most common surnames - 613 entries

Reformat copy-pasted table into a list of the most common surnames

  • Best score: 23
  • Best player score: 26
  • Position: #68 / 193
  • Number of attempts: 5
Change the content of a string - 1425 entries

This docstring is a complete lie. Fix it.

  • Best score: 22
  • Best player score: 22
  • Position: #93 / 542
  • Number of attempts: 3
Sort and add attributes - 1273 entries

Sort the states and add the attribute country to each record.

  • Best score: 33
  • Best player score: 33
  • Position: #136 / 510
  • Number of attempts: 3
Add fold markers to a .c file - 526 entries

Fold markers can make it easier to navigate source code. Add them to this .c file.

  • Best score: 30
  • Best player score: 34
  • Position: #72 / 165
  • Number of attempts: 4
Reconstruct the Sentence - 1265 entries

Get the sentence back in the proper order, remove duplicate lines, and then combine the separate lines into one.

  • Best score: 20
  • Best player score: 20
  • Position: #67 / 366
  • Number of attempts: 10
Braces or Brackets? - 779 entries

Someone forgot whether to use braces or brackets and you have to clean up their code!

  • Best score: 34
  • Best player score: 34
  • Position: #13 / 268
  • Number of attempts: 8
Whitespace, empty lines and tabs - 3136 entries

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

  • Best score: 16
  • Best player score: 17
  • Position: #65 / 699
  • Number of attempts: 9
Flodder-challenge - 1006 entries

Replace the text the most efficient and win!

  • Best score: 27
  • Best player score: 33
  • Position: #96 / 294
  • Number of attempts: 13
Simple text editing with Vim - 11962 entries

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

  • Best score: 13
  • Best player score: 13
  • Position: #122 / 3502
  • Number of attempts: 12
Reformat/Refactor a Golfer Class - 6336 entries

A simple case of removing unneeded code and fixing broken indentation.

  • Best score: 32
  • Best player score: 33
  • Position: #217 / 1561
  • Number of attempts: 6

Contributed Challenges

readability - 310 entries

Make the code readable by adding some spaces

camel riding - 765 entries

add a prefix on some camelCase variables

Yann Moisan
Twitter:

Scala enthusiast. Software craftsman. NoSQL.

entered into 115 challenges

contributed 2 challenges