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

XML to JSON - 41 entries

Convert this xml file into json.

  • Best score: 75
  • Best player score: 141
  • Number of attempts: 4
Define to require - 113 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
  • Number of attempts: 2
Execute immediate SQL - 72 entries

Sql string tranformation ...

  • Best score: 60
  • Best player score: 70
  • Number of attempts: 4
Calculate the table totals - 105 entries

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

  • Best score: 33
  • Best player score: 65
  • Number of attempts: 1
Create a pandoc compatible table - 136 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
  • Number of attempts: 4
expand a list comprehension (python) - 240 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
  • Number of attempts: 4
Change your calendar - 239 entries

Happy New Year!

  • Best score: 18
  • Best player score: 46
  • Number of attempts: 3
Python Hello World! Reformatting - 822 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
  • Number of attempts: 1
Convert pandoc unordered list to a numbered list - 130 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
  • Number of attempts: 5
Split the words - 334 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
  • Number of attempts: 3
Dehamlizing - 155 entries

Change this piece of HAML code back into erb

  • Best score: 32
  • Best player score: 42
  • Number of attempts: 5
Fix the Haiku - 246 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
  • Number of attempts: 3
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
  • Number of attempts: 1
Ruby 1.9 compat - 548 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
  • Number of attempts: 3
quotes inside quotes - 2684 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: 2
  • Best player score: 15
  • Number of attempts: 5
vim = 22 / 7 - 398 entries

pi square vim

  • Best score: 20
  • Best player score: 20
  • Number of attempts: 13
Space out the alphabet - 1318 entries

Put 3 spaces between adjacent letters.

  • Best score: 15
  • Best player score: 15
  • Number of attempts: 8
The Cake is a Lie - 1106 entries

Correct the capitalization of each word

  • Best score: 9
  • Best player score: 9
  • Number of attempts: 7
Hatsuyume - 360 entries

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

  • Best score: 16
  • Best player score: 31
  • Number of attempts: 2
A Simple One - 828 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
  • Number of attempts: 1
Make Fancy Header - 891 entries

Make the header text stand out with surrounding asterisks

  • Best score: 16
  • Best player score: 16
  • Number of attempts: 5
Words in parens - 10644 entries

We should all ace this, right?

  • Best score: 14
  • Best player score: 14
  • Number of attempts: 7
Add fold markers to a .c file - 441 entries

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

  • Best score: 30
  • Best player score: 34
  • Number of attempts: 4
Make it more readable - 1719 entries

Insert blank lines to make it more organized and readable

  • Best score: 13
  • Best player score: 14
  • Number of attempts: 5
SFD-ROC: vimvimvim - 1257 entries

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

  • Best score: 8
  • Best player score: 8
  • Number of attempts: 11
Sort the cardinal numbers - 211 entries

Maybe a simple challenge.

  • Best score: 12
  • Best player score: 46
  • Number of attempts: 3
camel riding - 678 entries

add a prefix on some camelCase variables

  • Best score: 15
  • Best player score: 18
  • Number of attempts: 1
Circle in a square - 125 entries

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

  • Best score: 23
  • Best player score: 69
  • Number of attempts: 3
Not enough Ps - 44 entries

Different type of code

  • Best score: 13
  • Best player score: 13
  • Number of attempts: 2
NBCU Weekly Challenge - Test - 214 entries

Just testing.

  • Best score: 18
  • Best player score: 20
  • Number of attempts: 2
Create Leading Zeros - 192 entries

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

  • Best score: 23
  • Best player score: 23
  • Number of attempts: 6
Simple text editing with Vim - 10129 entries

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

  • Best score: 13
  • Best player score: 13
  • Number of attempts: 12
Shuffle puzzle - 289 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
  • Number of attempts: 10
Happy TvvO - 344 entries

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

  • Best score: 12
  • Best player score: 12
  • Number of attempts: 4
VimGolfNight - 451 entries

Based on "The name of the game".

  • Best score: 12
  • Best player score: 12
  • Number of attempts: 3
Prefixes and suffixes - 485 entries

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

  • Best score: 17
  • Best player score: 23
  • Number of attempts: 5
-a-b-c- - 2474 entries

Put hyphens everywhere.

  • Best score: 13
  • Best player score: 13
  • Number of attempts: 4
Stairs Indenting - 359 entries

Indent each line with <line number> whitespaces.

  • Best score: 12
  • Best player score: 12
  • Number of attempts: 8
Almost encrypted - 164 entries

Convert the first paragraph to be even less readable.

  • Best score: 5
  • Best player score: 5
  • Number of attempts: 1
Remove noise from HTTP log - 597 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
  • Number of attempts: 3
Reconstruct the Sentence - 1010 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
  • Number of attempts: 10
I forgot quotes - 10858 entries

Oops.

  • Best score: 10
  • Best player score: 10
  • Number of attempts: 6
Minimalist Limerick - 448 entries

Reproduce this lovely poem.

  • Best score: 31
  • Best player score: 34
  • Number of attempts: 8
A simple change - 354 entries

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

  • Best score: 12
  • Best player score: 12
  • Number of attempts: 5
Increment, increment, increment.... - 479 entries

Vim likes macros

  • Best score: 10
  • Best player score: 12
  • Number of attempts: 2
The name of the game - 579 entries

End up with the name of the game.

  • Best score: 11
  • Best player score: 11
  • Number of attempts: 2
A HAPPY NEW YEAR 2014 ! - 9280 entries

A HAPPY NEW YEAR 2014 !

  • Best score: 11
  • Best player score: 12
  • Number of attempts: 4
Sort the VimGolf challenges by popularity - 250 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
  • Number of attempts: 8
Just the middle - 8769 entries

Delete the instructions at the top and bottom.

  • Best score: 7
  • Best player score: 7
  • Number of attempts: 4
Braces or Brackets? - 625 entries

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

  • Best score: 34
  • Best player score: 34
  • Number of attempts: 8
Context Insensitive completion 1 - 388 entries

Finish writing this simple Python HTTP server.

  • Best score: 18
  • Best player score: 18
  • Number of attempts: 1
Reformat most common surnames - 520 entries

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

  • Best score: 23
  • Best player score: 26
  • Number of attempts: 5
Exchanging Quotes - 746 entries

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

  • Best score: 30
  • Best player score: 35
  • Number of attempts: 5
Shebangs for all - 1568 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
  • Number of attempts: 10
Let's play some Ivmgolf - 879 entries

Oops, I spelled that wrong.

  • Best score: 7
  • Best player score: 7
  • Number of attempts: 6
Remove semicolons after expressions - 441 entries

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

  • Best score: 6
  • Best player score: 6
  • Number of attempts: 3
you're stuck on jQuery < 1.7 - 314 entries

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

  • Best score: 25
  • Best player score: 25
  • Number of attempts: 8
Wrap the text of an email message to 79 characters - 481 entries

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

  • Best score: 5
  • Best player score: 5
  • Number of attempts: 1
Extract text from xml - 101 entries

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

  • Best score: 28
  • Best player score: 35
  • Number of attempts: 3
readability - 285 entries

Make the code readable by adding some spaces

  • Best score: 18
  • Best player score: 24
  • Number of attempts: 6
Switch function arguments - 1795 entries

How to switch two arguments of a function.

  • Best score: 11
  • Best player score: 11
  • Number of attempts: 5
Reverse characters in a line - 563 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
  • Number of attempts: 3
Vertical Limit - 2063 entries

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

  • Best score: 21
  • Best player score: 23
  • Number of attempts: 8
The meaning - 491 entries

Numbers are fun!

  • Best score: 5
  • Best player score: 5
  • Number of attempts: 3
Delete unwanted lines - 333 entries

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

  • Best score: 9
  • Best player score: 9
  • Number of attempts: 2
Going underground.... - 283 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
  • Number of attempts: 1
The Quick Brown Fox Jumps Over The Lazy Vim - 320 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: 10
  • Best player score: 10
  • Number of attempts: 2
Counting in binary - 364 entries

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

  • Best score: 16
  • Best player score: 38
  • Number of attempts: 5
Mute the second method of this script - 404 entries

prepend a # infront of every line of the second method

  • Best score: 9
  • Best player score: 9
  • Number of attempts: 8
Assignment Alignment - 660 entries

line up the operators. Use spaces, not tabs.

  • Best score: 18
  • Best player score: 20
  • Number of attempts: 5
NATO phonetic alphabet - 385 entries

Transform the series of words into a list.

  • Best score: 19
  • Best player score: 21
  • Number of attempts: 2
Swap assigned value - 489 entries

Simple problem but looking for interesting solutions.

  • Best score: 10
  • Best player score: 10
  • Number of attempts: 6
Append semicolon after expressions - 841 entries

Some lines need the semicolon, some don't.

  • Best score: 11
  • Best player score: 11
  • Number of attempts: 4
abcd > a b c d - 239 entries

transform the single spaces into 4 spaces repeat for each line

  • Best score: 15
  • Best player score: 15
  • Number of attempts: 1
Letter case trickery - 1416 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
  • Number of attempts: 4
Search and Replace 0 - 3921 entries

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

  • Best score: 12
  • Best player score: 12
  • Number of attempts: 6
replacing each line of a block selection - 2440 entries

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

  • Best score: 17
  • Best player score: 20
  • Number of attempts: 6
Reverse and double space - 408 entries

Reverse the order of the given lines and double space everything

  • Best score: 14
  • Best player score: 14
  • Number of attempts: 6
Saving the hashes(#) - 1688 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
  • Number of attempts: 7
Hole-in-one - 935 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
  • Number of attempts: 7
Context insensitive completion 0 - 443 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: 7
  • Best player score: 7
  • Number of attempts: 3
Groups magic - 134 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
  • Number of attempts: 4
Python: Lots of function arguments - 66 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
  • Number of attempts: 3
lamb had a little Mary - 464 entries

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

  • Best score: 16
  • Best player score: 16
  • Number of attempts: 7
Whitespace, empty lines and tabs - 2518 entries

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

  • Best score: 16
  • Best player score: 17
  • Number of attempts: 9
Numbering a List - 1716 entries

Pretty simple, number the list.

  • Best score: 13
  • Best player score: 18
  • Number of attempts: 7
Mess in revision history - 936 entries

Help Joe clean up what Steve has cobbled.

  • Best score: 17
  • Best player score: 18
  • Number of attempts: 13
Fix the XML - 837 entries

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

  • Best score: 18
  • Best player score: 18
  • Number of attempts: 7
Flodder-challenge - 804 entries

Replace the text the most efficient and win!

  • Best score: 27
  • Best player score: 33
  • Number of attempts: 13
imports alignment (python) - 577 entries

Align as one import per line.

  • Best score: 17
  • Best player score: 19
  • Number of attempts: 9
Neither Fizz nor Buzz - 188 entries

Not your regular increment macro! The gaps are tricky.

  • Best score: 13
  • Best player score: 20
  • Number of attempts: 4
Python to Ruby - 188 entries

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

  • Best score: 24
  • Best player score: 27
  • Number of attempts: 8
Don't know what this is - 1669 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
  • Number of attempts: 9
remove dupes from array - 1179 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
  • Number of attempts: 6
Change the content of a string - 1208 entries

This docstring is a complete lie. Fix it.

  • Best score: 22
  • Best player score: 22
  • Number of attempts: 3
Indentation - 406 entries

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

  • Best score: 21
  • Best player score: 24
  • Number of attempts: 6
Enumerate words - 219 entries

Enumerate the unique words in order.

  • Best score: 23
  • Best player score: 26
  • Number of attempts: 5
Table Reshuffle - 316 entries

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

  • Best score: 22
  • Best player score: 24
  • Number of attempts: 6
PHP <--> Java class conversion Part 1 - 178 entries

Convert this tiny php class to adequate java one.

  • Best score: 65
  • Best player score: 84
  • Number of attempts: 4
Insert a Markdown link - 377 entries

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

  • Best score: 22
  • Best player score: 24
  • Number of attempts: 10
Extract argument from function - 1928 entries

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

  • Best score: 13
  • Best player score: 13
  • Number of attempts: 6
Another Mixed-Up Haiku - 196 entries

VimGolf ... a perfect evening?

  • Best score: 21
  • Best player score: 21
  • Number of attempts: 3
Sorting database text output - 183 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
  • Number of attempts: 6
Reformat a C golf submission - 468 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: 23
  • Best player score: 25
  • Number of attempts: 9
Logging with key - 275 entries

Sometimes it is better to log with meaningful key

  • Best score: 21
  • Best player score: 21
  • Number of attempts: 13
Coordinates placeholder - 49 entries

Place coordinates instead of target search.

  • Best score: 22
  • Best player score: 26
  • Number of attempts: 1
Sorting paragraphs - 443 entries

Order the paragraphs correctly, per prefixed index

  • Best score: 18
  • Best player score: 27
  • Number of attempts: 8
Change name of a variable - 143 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
  • Number of attempts: 1
O Christmas Tree - 99 entries

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

  • Best score: 22
  • Best player score: 31
  • Number of attempts: 2
Java Array2List - 213 entries

Convert an java array initializer into a list.

  • Best score: 67
  • Best player score: 112
  • Number of attempts: 3
Reformat/Refactor a Golfer Class - 5391 entries

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

  • Best score: 32
  • Best player score: 33
  • Number of attempts: 6
Sort and add attributes - 1059 entries

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

  • Best score: 18
  • Best player score: 33
  • Number of attempts: 3
Replacing some words - 405 entries

How fast could it be?

  • Best score: 2
  • Best player score: 20
  • Number of attempts: 4
SFD-ROC: Tic-Tac-Toe - 124 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
  • Number of attempts: 5
attr_aligner - 2847 entries

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

  • Best score: 19
  • Best player score: 34
  • Number of attempts: 2

Contributed Challenges

camel riding - 678 entries

add a prefix on some camelCase variables

readability - 285 entries

Make the code readable by adding some spaces

Yann Moisan
Twitter:

Scala enthusiast. Software craftsman. NoSQL.

entered into 115 challenges

contributed 2 challenges