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

pi square vim

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

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

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

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

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

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

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

Delete the instructions at the top and bottom.

  • Best score: 7
  • Best player score: 7
  • Position: #139 / 4114
  • Number of attempts: 4
Python Hello World! Reformatting - 906 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: #151 / 352
  • Number of attempts: 1
Create Leading Zeros - 205 entries

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

  • Best score: 23
  • Best player score: 23
  • Position: #5 / 77
  • 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 - 561 entries

Simple problem but looking for interesting solutions.

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

Happy New Year!

  • Best score: 18
  • Best player score: 46
  • Position: #76 / 79
  • Number of attempts: 3
VimGolfNight - 505 entries

Based on "The name of the game".

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

add a prefix on some camelCase variables

  • Best score: 15
  • Best player score: 18
  • Position: #189 / 267
  • Number of attempts: 1
readability - 306 entries

Make the code readable by adding some spaces

  • Best score: 18
  • Best player score: 24
  • Position: #141 / 145
  • Number of attempts: 6
Logging with key - 292 entries

Sometimes it is better to log with meaningful key

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

Put 3 spaces between adjacent letters.

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

Different type of code

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

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

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

prepend a # infront of every line of the second method

  • Best score: 9
  • Best player score: 9
  • Position: #34 / 233
  • Number of attempts: 8
Sorting database text output - 206 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 / 79
  • Number of attempts: 6
Happy TvvO - 392 entries

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

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

Oops.

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

Put hyphens everywhere.

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

Just testing.

  • Best score: 18
  • Best player score: 20
  • Position: #74 / 112
  • Number of attempts: 2
Change name of a variable - 163 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 / 127
  • Number of attempts: 1
Neither Fizz nor Buzz - 221 entries

Not your regular increment macro! The gaps are tricky.

  • Best score: 13
  • Best player score: 20
  • Position: #48 / 97
  • Number of attempts: 4
Don't know what this is - 1951 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 / 572
  • Number of attempts: 9
Mess in revision history - 1143 entries

Help Joe clean up what Steve has cobbled.

  • Best score: 17
  • Best player score: 18
  • Position: #77 / 242
  • Number of attempts: 13
Shuffle puzzle - 307 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 / 100
  • 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 - 353 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: #91 / 106
  • Number of attempts: 3
A HAPPY NEW YEAR 2014 ! - 10538 entries

A HAPPY NEW YEAR 2014 !

  • Best score: 11
  • Best player score: 12
  • Position: #1599 / 3638
  • Number of attempts: 4
attr_aligner - 3402 entries

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

  • Best score: 19
  • Best player score: 34
  • Position: #530 / 685
  • 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 - 412 entries

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

  • Best score: 16
  • Best player score: 38
  • Position: #67 / 108
  • Number of attempts: 5
Letter case trickery - 1553 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: #183 / 500
  • Number of attempts: 4
quotes inside quotes - 3030 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: #385 / 1045
  • Number of attempts: 5
Sort the VimGolf challenges by popularity - 338 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 / 102
  • Number of attempts: 8
Words in parens - 12736 entries

We should all ace this, right?

  • Best score: 13
  • Best player score: 14
  • Position: #206 / 3919
  • Number of attempts: 7
Hole-in-one - 978 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: #205 / 298
  • Number of attempts: 7
Delete unwanted lines - 358 entries

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

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

Reproduce this lovely poem.

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

Place coordinates instead of target search.

  • Best score: 22
  • Best player score: 26
  • Position: #28 / 35
  • 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 - 235 entries

Enumerate the unique words in order.

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

Sql string tranformation ...

  • Best score: 60
  • Best player score: 70
  • Position: #10 / 29
  • Number of attempts: 4
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
  • Position: #36 / 48
  • Number of attempts: 3
Groups magic - 142 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 / 85
  • Number of attempts: 4
Prefixes and suffixes - 567 entries

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

  • Best score: 17
  • Best player score: 23
  • Position: #43 / 185
  • Number of attempts: 5
abcd > a b c d - 263 entries

transform the single spaces into 4 spaces repeat for each line

  • Best score: 15
  • Best player score: 15
  • Position: #70 / 207
  • Number of attempts: 1
Python: Lots of function arguments - 81 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: #32 / 40
  • Number of attempts: 3
Dehamlizing - 174 entries

Change this piece of HAML code back into erb

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

Transform the series of words into a list.

  • Best score: 19
  • Best player score: 21
  • Position: #76 / 182
  • Number of attempts: 2
Create a pandoc compatible table - 176 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: #37 / 50
  • Number of attempts: 4
A simple change - 401 entries

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

  • Best score: 12
  • Best player score: 12
  • Position: #17 / 177
  • Number of attempts: 5
SFD-ROC: Tic-Tac-Toe - 131 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 / 49
  • Number of attempts: 5
Extract text from xml - 102 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 / 42
  • Number of attempts: 3
The Quick Brown Fox Jumps Over The Lazy Vim - 388 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: #61 / 180
  • Number of attempts: 2
The name of the game - 629 entries

End up with the name of the game.

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

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

  • Best score: 16
  • Best player score: 16
  • Position: #4 / 157
  • Number of attempts: 7
SFD-ROC: vimvimvim - 1510 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 / 424
  • Number of attempts: 11
Stairs Indenting - 428 entries

Indent each line with <line number> whitespaces.

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

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

  • Best score: 24
  • Best player score: 27
  • Position: #24 / 56
  • Number of attempts: 8
Saving the hashes(#) - 1966 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: #86 / 467
  • 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 - 1015 entries

Oops, I spelled that wrong.

  • Best score: 7
  • Best player score: 7
  • Position: #53 / 420
  • Number of attempts: 6
you're stuck on jQuery < 1.7 - 330 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 / 107
  • Number of attempts: 8
Vertical Limit - 2377 entries

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

  • Best score: 21
  • Best player score: 23
  • Position: #199 / 719
  • Number of attempts: 8
Exchanging Quotes - 799 entries

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

  • Best score: 30
  • Best player score: 35
  • Position: #92 / 219
  • Number of attempts: 5
replacing each line of a block selection - 2816 entries

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

  • Best score: 18
  • Best player score: 20
  • Position: #232 / 736
  • Number of attempts: 6
Switch function arguments - 1985 entries

How to switch two arguments of a function.

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

Some lines need the semicolon, some don't.

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

Reverse the order of the given lines and double space everything

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

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

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

Numbers are fun!

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

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

  • Best score: 33
  • Best player score: 65
  • Position: #28 / 40
  • Number of attempts: 1
Replacing some words - 417 entries

How fast could it be?

  • Best score: 17
  • Best player score: 20
  • Position: #61 / 146
  • 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 - 280 entries

Maybe a simple challenge.

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

Insert blank lines to make it more organized and readable

  • Best score: 13
  • Best player score: 14
  • Position: #141 / 625
  • Number of attempts: 5
remove dupes from array - 1290 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: #142 / 325
  • Number of attempts: 6
imports alignment (python) - 648 entries

Align as one import per line.

  • Best score: 17
  • Best player score: 19
  • Position: #61 / 192
  • Number of attempts: 9
expand a list comprehension (python) - 291 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 / 104
  • Number of attempts: 4
Insert a Markdown link - 420 entries

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

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

Pretty simple, number the list.

  • Best score: 13
  • Best player score: 18
  • Position: #103 / 627
  • 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 - 782 entries

line up the operators. Use spaces, not tabs.

  • Best score: 18
  • Best player score: 20
  • Position: #80 / 211
  • Number of attempts: 5
Shebangs for all - 1777 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 / 468
  • Number of attempts: 10
A Simple One - 934 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 / 617
  • Number of attempts: 1
Table Reshuffle - 357 entries

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

  • Best score: 22
  • Best player score: 24
  • Position: #33 / 128
  • Number of attempts: 6
Another Mixed-Up Haiku - 228 entries

VimGolf ... a perfect evening?

  • Best score: 21
  • Best player score: 21
  • Position: #28 / 82
  • Number of attempts: 3
Ruby 1.9 compat - 597 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: #129 / 226
  • Number of attempts: 3
Increment, increment, increment.... - 591 entries

Vim likes macros

  • Best score: 10
  • Best player score: 12
  • Position: #227 / 378
  • Number of attempts: 2
Sorting paragraphs - 495 entries

Order the paragraphs correctly, per prefixed index

  • Best score: 18
  • Best player score: 27
  • Position: #63 / 153
  • Number of attempts: 8
Indentation - 452 entries

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

  • Best score: 21
  • Best player score: 24
  • Position: #38 / 160
  • Number of attempts: 6
Hatsuyume - 423 entries

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

  • Best score: 16
  • Best player score: 31
  • Position: #122 / 167
  • Number of attempts: 2
The Cake is a Lie - 1215 entries

Correct the capitalization of each word

  • Best score: 9
  • Best player score: 9
  • Position: #135 / 491
  • Number of attempts: 7
Fix the Haiku - 265 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: #53 / 106
  • Number of attempts: 3
Context insensitive completion 0 - 474 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
  • Position: #75 / 223
  • Number of attempts: 3
Context Insensitive completion 1 - 436 entries

Finish writing this simple Python HTTP server.

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

Convert the first paragraph to be even less readable.

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

Make the header text stand out with surrounding asterisks

  • Best score: 16
  • Best player score: 16
  • Position: #78 / 329
  • Number of attempts: 5
Reformat a C golf submission - 536 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: #14 / 195
  • Number of attempts: 9
Reverse characters in a line - 645 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: #118 / 236
  • Number of attempts: 3
Reformat most common surnames - 593 entries

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

  • Best score: 23
  • Best player score: 26
  • Position: #65 / 187
  • Number of attempts: 5
Change the content of a string - 1354 entries

This docstring is a complete lie. Fix it.

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

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

  • Best score: 33
  • Best player score: 33
  • Position: #136 / 490
  • Number of attempts: 3
Add fold markers to a .c file - 493 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: #69 / 158
  • Number of attempts: 4
Reconstruct the Sentence - 1160 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 / 348
  • Number of attempts: 10
Braces or Brackets? - 713 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 / 253
  • Number of attempts: 8
Whitespace, empty lines and tabs - 3009 entries

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

  • Best score: 16
  • Best player score: 17
  • Position: #63 / 667
  • Number of attempts: 9
Flodder-challenge - 927 entries

Replace the text the most efficient and win!

  • Best score: 27
  • Best player score: 33
  • Position: #89 / 273
  • Number of attempts: 13
Simple text editing with Vim - 11657 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 / 3418
  • Number of attempts: 12
Reformat/Refactor a Golfer Class - 6033 entries

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

  • Best score: 32
  • Best player score: 33
  • Position: #216 / 1486
  • Number of attempts: 6

Contributed Challenges

readability - 306 entries

Make the code readable by adding some spaces

camel riding - 745 entries

add a prefix on some camelCase variables

Yann Moisan
Twitter:

Scala enthusiast. Software craftsman. NoSQL.

entered into 115 challenges

contributed 2 challenges