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]

32802 active golfers, 395555 entries, 535 challenges

Open VimGolf challenges

Assign list - 146 entries

Assign list elements to matrix

Across-Down Flip - 45 entries

Do this instead of the Sunday crossword.

Number an outline - 218 entries

The indent and words are right, but the numbers are all wrong.

Change The Perspective - 36 entries

This is a go game recodes file(.sgf file, refer to It base on such a coordinate system: in vertical direction, is from top(farthest end) to bottom, mark as a,b,c,...,s(19*19 board); in horizontal direction, is from left to right, uses the same notations. For Example, the coordinate notation 'cq', is the position at the bottom-left corner(vertical coordinate first). The record is from one player's perspective. We need to change to another's, but we don't want to change coordinate system, let it keep top to bottom and left to right. so we have to change the coordinates, a <-> s, b <-> r,c <-> q, etc. the Position 'cq', as transformation, it will be 'qd'.

paste indent correction - JS - 89 entries

You copy some javascript code from a website and paste it into vim, it does not look good!

Draw the Go board - 138 entries

which is a 19×19 lines board. Here we use ascii characters only for simplicity. See diff file to get a sense. (See also

Words in parens - 12721 entries

We should all ace this, right?

Lookahead and Lookbehind - 65 entries

Look everywhere

It's a factor - 91 entries

Flaunt your macro prowess by factoring some numbers. Too hard? It takes less than 30 strokes, I promise.

Sort the VimGolf challenges by popularity - 336 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 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!

Extended Customer 2 - 44 entries

Format the chars

Parsing with CSV: Unify lines and result. - 164 entries

col1;col2;col3;col4 A;1;4;5 A;3;4; A;1;4; # New output: col1;col2;col3;col4 A;1(2x);3;4(3x);5 any ideas?

Fibonacci Triangles - 47 entries


199 Fibonacci Numbers - 37 entries

Generate 199 Fibonacci Numbers using, if you like, the function S(x,y), a vimscript to sum two big numbers in reverse order.

Refactor arguments into object argument - 160 entries

A relatively common Javascript refactoring.

vim = 22 / 7 - 422 entries

pi square vim

Chinese Multiplication Table - 70 entries

Print a Chinese multiplication table in Vim. In China, every kid is asked to memorize this table. And thanks to the mono-syllabism of Chinese characters, it is not that hard. Printing the multiplication table is also a good exercise for programming beginners. For-loop, escaped characters, etc... There should be some special ways to print it in Vim.

LaTeX to XML Math Delimiters - 40 entries

Vim is amazing when used to edit MediaWiki text, but typing "<math> . . . </math>" can be tiresome and frustrating if formulas are used often. LaTeX delimiters are so concise and even come in two flavors: "\( . . . \)" for inline math and "\[ . . . \]" for centered formulas. The goal is to perform the following conversions: "\( . . . \)" becomes "<math>. . .</math>" "\[ . . . \]" becomes "<center><math>. . .</math></center>"

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.

Minimalist Limerick - 503 entries

Reproduce this lovely poem.

Saving the hashes(#) - 1948 entries

The following file is copied from 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.

Word frequency alignment - 235 entries

You've got to align the second column, but the spacing is inconvenient and there are nasty tabs in the way. If you're a "real Vim ninja," this could be very quick indeed...

Circle in a square - 125 entries

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

Execute immediate SQL - 84 entries

Sql string tranformation ...

Prefixes and suffixes - 559 entries

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

Coordinates placeholder - 56 entries

Place coordinates instead of target search.

XML to JSON - 44 entries

Convert this xml file into json.

Change your calendar - 278 entries

Happy New Year!

Greek Letters - 59 entries

Starting with a list of Greek letters, create a cross-reference table showing all of the Greek alpha-beta. You'll likely need to use digraphs (:help digraphs). Note that while most digraphs can be entered with either character first, lowercase sigma has two digraphs -- s* AND *s! Good luck!

Transposition - 73 entries

Transpose the original lines in separate columns, one for each line.

REDRUM - 139 entries

If you remember "The Shinning", the first time you saw the bloody word REDRUM you probably thinked "What the Hell is that?" Well, then you know that you need a little help from a looking-glass to make sense of it. Now it's time to use vim like a mirror to reveal the message.

Enumerate words - 230 entries

Enumerate the unique words in order.

Swap assigned value - 551 entries

Simple problem but looking for interesting solutions.

Groups magic - 141 entries

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

Block Fun 1 - 179 entries

Manipulate the columns to produce desired result.

fib.c cleanup - 58 entries

cleanup the file

Harder than "abcd > a b c d" - 75 entries

Not as easy as the last challenge. This time, just one space between a and b, up to 25 spaces between y and z. (Removed some lines; diff was too long.)

abcd > a b c d - 259 entries

transform the single spaces into 4 spaces repeat for each line

lamb had a little Mary - 550 entries

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

Python: Lots of function arguments - 73 entries

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

Checkerboard case pattern - 128 entries

All the squares are white. Make some of them black. But only the right ones.

Readable Rubyhash - 238 entries

Rubyists talk about being cutting edge but how many are using 1.9 in production? Time to convert those verbose 1.8 hashes in to symbolic, succinct 1.9 beauties!

Chucking wood - 80 entries

An exercise in compressing repetitive text. For this challenge, any entry that uses keys outside the main row (such as arrow keys, Home, End, Delete, etc.) will be removed. (Esc is OK, though you should be using C-[ anyway.)

Flip the chessboard - 67 entries

White's turn is over. Flip the board to black's perspective. I added coordinates to frustrate you.

Extract text from xml - 102 entries

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

Printable ASCII characters - 95 entries

From a blank input, print all 95 printing ASCII characters one per line, from space to tilde.

A simple change - 393 entries

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

Let's play some Ivmgolf - 997 entries

Oops, I spelled that wrong.

Unwrap the text of an email message - 164 entries

Reverse of "Wrap the text of an email message to 79 characters". gq and gw are great for wrapping paragraphs. But sometimes other programs choke on your wrapped lines. What's the best way to un-gq?

Sort by your own sum - 49 entries

Same numbers as last time, but you'll have to add them yourself.

VimGolf Chatter