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 - 676 entries

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

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

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

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

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

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

Delete the instructions at the top and bottom.

  • Best score: 7
  • Best player score: 7
  • Position: #139 / 4160
  • Number of attempts: 4
Python Hello World! Reformatting - 936 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 / 363
  • Number of attempts: 1
Create Leading Zeros - 232 entries

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

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

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

  • Best score: 22
  • Best player score: 31
  • Position: #32 / 42
  • Number of attempts: 2
Swap assigned value - 614 entries

Simple problem but looking for interesting solutions.

  • Best score: 10
  • Best player score: 10
  • Position: #58 / 247
  • 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 - 531 entries

Based on "The name of the game".

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

add a prefix on some camelCase variables

  • Best score: 15
  • Best player score: 18
  • Position: #196 / 274
  • Number of attempts: 1
readability - 312 entries

Make the code readable by adding some spaces

  • Best score: 18
  • Best player score: 24
  • Position: #143 / 148
  • 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 - 1627 entries

Put 3 spaces between adjacent letters.

  • Best score: 15
  • Best player score: 15
  • Position: #5 / 440
  • 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 - 996 entries

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

  • Best score: 18
  • Best player score: 18
  • Position: #13 / 284
  • 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 - 219 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 / 81
  • Number of attempts: 6
Happy TvvO - 403 entries

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

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

Oops.

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

Put hyphens everywhere.

  • Best score: 13
  • Best player score: 13
  • Position: #72 / 1127
  • 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 - 1978 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 / 578
  • 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.... - 330 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: #33 / 124
  • 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 ! - 10616 entries

A HAPPY NEW YEAR 2014 !

  • Best score: 11
  • Best player score: 12
  • Position: #1616 / 3663
  • Number of attempts: 4
attr_aligner - 3444 entries

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

  • Best score: 19
  • Best player score: 34
  • Position: #536 / 692
  • 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 - 477 entries

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

  • Best score: 16
  • Best player score: 38
  • Position: #69 / 113
  • Number of attempts: 5
Letter case trickery - 1594 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 / 511
  • Number of attempts: 4
quotes inside quotes - 3124 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: #399 / 1071
  • Number of attempts: 5
Sort the VimGolf challenges by popularity - 345 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 / 105
  • Number of attempts: 8
Words in parens - 12850 entries

We should all ace this, right?

  • Best score: 13
  • Best player score: 14
  • Position: #215 / 3944
  • 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 - 396 entries

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

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

Reproduce this lovely poem.

  • Best score: 31
  • Best player score: 34
  • Position: #54 / 171
  • 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 - 248 entries

Enumerate the unique words in order.

  • Best score: 23
  • Best player score: 26
  • Position: #41 / 88
  • 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 - 591 entries

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

  • Best score: 17
  • Best player score: 23
  • Position: #46 / 192
  • 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 - 101 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 / 45
  • Number of attempts: 3
Dehamlizing - 179 entries

Change this piece of HAML code back into erb

  • Best score: 32
  • Best player score: 42
  • Position: #42 / 69
  • 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 - 181 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: #39 / 53
  • 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 - 400 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 / 187
  • Number of attempts: 2
The name of the game - 646 entries

End up with the name of the game.

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

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

  • Best score: 16
  • Best player score: 16
  • Position: #4 / 161
  • Number of attempts: 7
SFD-ROC: vimvimvim - 1569 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 / 437
  • Number of attempts: 11
Stairs Indenting - 446 entries

Indent each line with <line number> whitespaces.

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

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

  • Best score: 24
  • Best player score: 27
  • Position: #25 / 58
  • Number of attempts: 8
Saving the hashes(#) - 1992 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 / 473
  • Number of attempts: 7
Convert pandoc unordered list to a numbered list - 163 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: #47 / 56
  • Number of attempts: 5
Let's play some Ivmgolf - 1084 entries

Oops, I spelled that wrong.

  • Best score: 7
  • Best player score: 7
  • Position: #53 / 440
  • 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 - 2436 entries

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

  • Best score: 21
  • Best player score: 23
  • Position: #202 / 735
  • Number of attempts: 8
Exchanging Quotes - 820 entries

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

  • Best score: 30
  • Best player score: 35
  • Position: #95 / 224
  • Number of attempts: 5
replacing each line of a block selection - 2925 entries

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

  • Best score: 18
  • Best player score: 20
  • Position: #241 / 764
  • Number of attempts: 6
Switch function arguments - 2064 entries

How to switch two arguments of a function.

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

Some lines need the semicolon, some don't.

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

Reverse the order of the given lines and double space everything

  • Best score: 14
  • Best player score: 14
  • Position: #41 / 194
  • Number of attempts: 6
Remove noise from HTTP log - 693 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 / 270
  • Number of attempts: 3
Remove semicolons after expressions - 628 entries

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

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

Numbers are fun!

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

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

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

How fast could it be?

  • Best score: 17
  • Best player score: 20
  • Position: #61 / 148
  • Number of attempts: 4
PHP <--> Java class conversion Part 1 - 212 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 - 293 entries

Maybe a simple challenge.

  • Best score: 12
  • Best player score: 46
  • Position: #141 / 146
  • Number of attempts: 3
Make it more readable - 1952 entries

Insert blank lines to make it more organized and readable

  • Best score: 13
  • Best player score: 14
  • Position: #145 / 640
  • Number of attempts: 5
remove dupes from array - 1332 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 / 330
  • Number of attempts: 6
imports alignment (python) - 661 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) - 301 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: #40 / 106
  • Number of attempts: 4
Insert a Markdown link - 431 entries

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

  • Best score: 22
  • Best player score: 24
  • Position: #61 / 143
  • Number of attempts: 10
Numbering a List - 1855 entries

Pretty simple, number the list.

  • Best score: 13
  • Best player score: 18
  • Position: #112 / 638
  • Number of attempts: 7
Java Array2List - 225 entries

Convert an java array initializer into a list.

  • Best score: 67
  • Best player score: 112
  • Position: #56 / 83
  • Number of attempts: 3
Assignment Alignment - 829 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 - 1904 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 / 497
  • Number of attempts: 10
A Simple One - 996 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 / 641
  • Number of attempts: 1
Table Reshuffle - 369 entries

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

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

VimGolf ... a perfect evening?

  • Best score: 21
  • Best player score: 21
  • Position: #28 / 85
  • Number of attempts: 3
Ruby 1.9 compat - 609 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.... - 643 entries

Vim likes macros

  • Best score: 10
  • Best player score: 12
  • Position: #241 / 398
  • Number of attempts: 2
Sorting paragraphs - 505 entries

Order the paragraphs correctly, per prefixed index

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

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

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

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

  • Best score: 16
  • Best player score: 31
  • Position: #128 / 174
  • Number of attempts: 2
The Cake is a Lie - 1284 entries

Correct the capitalization of each word

  • Best score: 9
  • Best player score: 9
  • Position: #135 / 511
  • Number of attempts: 7
Fix the Haiku - 275 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 / 109
  • Number of attempts: 3
Context insensitive completion 0 - 502 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: #77 / 231
  • Number of attempts: 3
Context Insensitive completion 1 - 456 entries

Finish writing this simple Python HTTP server.

  • Best score: 18
  • Best player score: 18
  • Position: #97 / 231
  • Number of attempts: 1
Almost encrypted - 198 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 - 1007 entries

Make the header text stand out with surrounding asterisks

  • Best score: 16
  • Best player score: 16
  • Position: #78 / 337
  • Number of attempts: 5
Reformat a C golf submission - 552 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 / 199
  • Number of attempts: 9
Reverse characters in a line - 709 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: #126 / 249
  • Number of attempts: 3
Reformat most common surnames - 644 entries

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

  • Best score: 23
  • Best player score: 26
  • Position: #70 / 197
  • Number of attempts: 5
Change the content of a string - 1457 entries

This docstring is a complete lie. Fix it.

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

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

  • Best score: 33
  • Best player score: 33
  • Position: #136 / 527
  • Number of attempts: 3
Add fold markers to a .c file - 550 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: #73 / 170
  • Number of attempts: 4
Reconstruct the Sentence - 1348 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 / 379
  • Number of attempts: 10
Braces or Brackets? - 870 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 / 284
  • Number of attempts: 8
Whitespace, empty lines and tabs - 3290 entries

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

  • Best score: 16
  • Best player score: 17
  • Position: #70 / 729
  • Number of attempts: 9
Flodder-challenge - 1086 entries

Replace the text the most efficient and win!

  • Best score: 27
  • Best player score: 33
  • Position: #101 / 305
  • Number of attempts: 13
Simple text editing with Vim - 12233 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 / 3567
  • Number of attempts: 12
Reformat/Refactor a Golfer Class - 6512 entries

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

  • Best score: 32
  • Best player score: 33
  • Position: #219 / 1603
  • Number of attempts: 6

Contributed Challenges

readability - 312 entries

Make the code readable by adding some spaces

camel riding - 769 entries

add a prefix on some camelCase variables

Yann Moisan
Twitter:

Scala enthusiast. Software craftsman. NoSQL.

entered into 115 challenges

contributed 2 challenges