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

pi square vim

  • Best score: 20
  • Best player score: 20
  • Position: #4 / 133
  • Number of attempts: 2
Wrap the text of an email message to 79 characters - 705 entries

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

  • Best score: 5
  • Best player score: 5
  • Position: #159 / 398
  • Number of attempts: 1
Search and Replace 0 - 4851 entries

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

  • Best score: 12
  • Best player score: 12
  • Position: #218 / 1604
  • Number of attempts: 5
Create Leading Zeros - 239 entries

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

  • Best score: 23
  • Best player score: 43
  • Position: #54 / 81
  • Number of attempts: 1
O Christmas Tree - 109 entries

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

  • Best score: 22
  • Best player score: 28
  • Position: #20 / 43
  • Number of attempts: 2
Mirror Symmetry - 812 entries

Add backslashes.

  • Best score: 7
  • Best player score: 7
  • Position: #20 / 268
  • Number of attempts: 2
Swap assigned value - 628 entries

Simple problem but looking for interesting solutions.

  • Best score: 10
  • Best player score: 10
  • Position: #30 / 252
  • Number of attempts: 2
Change your calendar - 363 entries

Happy New Year!

  • Best score: 18
  • Best player score: 31
  • Position: #41 / 86
  • Number of attempts: 2
Collect List - 4267 entries

Convert to comma separated list.

  • Best score: 12
  • Best player score: 15
  • Position: #669 / 1188
  • Number of attempts: 1
VimGolfNight - 538 entries

Based on "The name of the game".

  • Best score: 12
  • Best player score: 12
  • Position: #32 / 344
  • Number of attempts: 2
Condensed Cases - 794 entries

Apple's new programming language, Swift, allows two style of case statements: 1) one Enum case on each line, or 2) multiple Enum cases on a single line. Convert the following from the first case (no pun intended) to the second type.

  • Best score: 12
  • Best player score: 14
  • Position: #107 / 244
  • Number of attempts: 4
Pretty format for variable declarations - 156 entries

Project standards demand the equal signs must be aligned for better readability.

  • Best score: 13
  • Best player score: 18
  • Position: #42 / 63
  • Number of attempts: 2
I forgot quotes - 15946 entries

Oops.

  • Best score: 10
  • Best player score: 16
  • Position: #2382 / 4166
  • Number of attempts: 1
-a-b-c- - 3183 entries

Put hyphens everywhere.

  • Best score: 13
  • Best player score: 16
  • Position: #757 / 1132
  • Number of attempts: 1
Count both ways - 1006 entries

Right AND down.

  • Best score: 13
  • Best player score: 16
  • Position: #147 / 352
  • Number of attempts: 3
Two become one - 713 entries

We have two c arrays and want to make one two dimensional out of it. Can we do that?

  • Best score: 25
  • Best player score: 28
  • Position: #58 / 208
  • Number of attempts: 5
Mess in revision history - 1183 entries

Help Joe clean up what Steve has cobbled.

  • Best score: 17
  • Best player score: 33
  • Position: #209 / 249
  • Number of attempts: 2
Going underground.... - 349 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: #27 / 127
  • Number of attempts: 4
Split the words - 357 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: 40
  • Position: #69 / 109
  • Number of attempts: 1
A HAPPY NEW YEAR 2014 ! - 10652 entries

A HAPPY NEW YEAR 2014 !

  • Best score: 11
  • Best player score: 12
  • Position: #1625 / 3677
  • Number of attempts: 1
attr_aligner - 3454 entries

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

  • Best score: 19
  • Best player score: 30
  • Position: #351 / 695
  • Number of attempts: 2
Ninjas Leaderboard - 86 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: #20 / 40
  • Number of attempts: 1
Counting in binary - 478 entries

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

  • Best score: 16
  • Best player score: 22
  • Position: #34 / 114
  • Number of attempts: 1
Letter case trickery - 1598 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: #180 / 514
  • Number of attempts: 2
Untangle my tail, please! - 58 entries

You know, this words were playing to chase their tails and Oops! What happened? Now we have a complete mess, their tails are totally tangled, can you please help them to untangle their tails?

  • Best score: 16
  • Best player score: 17
  • Position: #14 / 32
  • Number of attempts: 1
quotes inside quotes - 3128 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: 16
  • Position: #517 / 1073
  • Number of attempts: 2
Hanging Indent for Footnotes - 70 entries

Format this footnote (in kramdown syntax) so that it has hanging indent.

  • Best score: 17
  • Best player score: 23
  • Position: #14 / 29
  • Number of attempts: 3
Recursive Cowsay - 59 entries

Convert 'cowsay' statement to recursive output

  • Best score: 33
  • Best player score: 40
  • Position: #8 / 18
  • Number of attempts: 10
Top X - 192 entries

The End File is the Top 10 Vimgolf Leaderboard at June 29, 2013. This is a second version, with a great contribution of @udioica. X is ten in Roman,a numeric system in ancient Rome

  • Best score: 18
  • Best player score: 21
  • Position: #10 / 70
  • Number of attempts: 6
Sort the VimGolf challenges by popularity - 346 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: #13 / 106
  • Number of attempts: 3
Number an outline - 252 entries

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

  • Best score: 25
  • Best player score: 66
  • Position: #58 / 76
  • Number of attempts: 1
Words in parens - 12868 entries

We should all ace this, right?

  • Best score: 13
  • Best player score: 14
  • Position: #30 / 3950
  • Number of attempts: 8
Pairs of numbers - 361 entries

Line 1 represents x, line 2 y-data. Bring the corresponding pairs in the form "[x,y]\n"

  • Best score: 26
  • Best player score: 27
  • Position: #8 / 134
  • Number of attempts: 3
Assign list - 170 entries

Assign list elements to matrix

  • Best score: 30
  • Best player score: 32
  • Position: #12 / 60
  • Number of attempts: 5
Draw the Go board - 141 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 http://en.wikipedia.org/wiki/Go_(game))

  • Best score: 50
  • Best player score: 60
  • Position: #14 / 49
  • Number of attempts: 2
Hole-in-one - 1017 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: 18
  • Position: #111 / 303
  • Number of attempts: 2
Delete unwanted lines - 398 entries

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

  • Best score: 9
  • Best player score: 9
  • Position: #9 / 227
  • Number of attempts: 1
Parsing with CSV: Unify lines and result. - 167 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?

  • Best score: 21
  • Best player score: 21
  • Position: #20 / 75
  • Number of attempts: 1
Lookahead and Lookbehind - 68 entries

Look everywhere

  • Best score: 16
  • Best player score: 20
  • Position: #12 / 30
  • Number of attempts: 3
Word frequency alignment - 278 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...

  • Best score: 5
  • Best player score: 5
  • Position: #40 / 159
  • Number of attempts: 1
LaTeX to XML Math Delimiters - 41 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>"

  • Best score: 63
  • Best player score: 92
  • Position: #13 / 19
  • Number of attempts: 2
Minimalist Limerick - 519 entries

Reproduce this lovely poem.

  • Best score: 30
  • Best player score: 33
  • Position: #46 / 173
  • Number of attempts: 3
Coordinates placeholder - 64 entries

Place coordinates instead of target search.

  • Best score: 22
  • Best player score: 26
  • Position: #26 / 37
  • Number of attempts: 1
Define to require - 119 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: 78
  • Position: #21 / 49
  • Number of attempts: 2
REDRUM - 151 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.

  • Best score: 14
  • Best player score: 14
  • Position: #8 / 63
  • Number of attempts: 4
Enumerate words - 251 entries

Enumerate the unique words in order.

  • Best score: 23
  • Best player score: 26
  • Position: #44 / 90
  • Number of attempts: 3
Execute immediate SQL - 87 entries

Sql string tranformation ...

  • Best score: 58
  • Best player score: 73
  • Position: #19 / 31
  • Number of attempts: 2
Block Fun 1 - 190 entries

Manipulate the columns to produce desired result.

  • Best score: 14
  • Best player score: 21
  • Position: #34 / 74
  • Number of attempts: 1
Groups magic - 157 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: #36 / 92
  • Number of attempts: 1
Prefixes and suffixes - 599 entries

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

  • Best score: 17
  • Best player score: 26
  • Position: #79 / 195
  • Number of attempts: 1
Sort by sum of numbers in a line(?) - 60 entries

The lines with the biggest sums need to be at the top. The sums are on the right, which makes life hard. Maybe you can find a feature that will do all the work for you...

  • Best score: 15
  • Best player score: 16
  • Position: #25 / 37
  • Number of attempts: 1
abcd > a b c d - 282 entries

transform the single spaces into 4 spaces repeat for each line

  • Best score: 15
  • Best player score: 15
  • Position: #68 / 220
  • Number of attempts: 1
Readable Rubyhash - 245 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!

  • Best score: 23
  • Best player score: 28
  • Position: #52 / 93
  • Number of attempts: 1
NATO phonetic alphabet - 506 entries

Transform the series of words into a list.

  • Best score: 19
  • Best player score: 19
  • Position: #8 / 194
  • Number of attempts: 5
SFD-ROC: The Quick Brown Fox - 175 entries

Someone has vandalized our text (again). Please fix to read: The Quick Brown Fox Jumps Over The Lazy Dog.

  • Best score: 24
  • Best player score: 28
  • Position: #65 / 104
  • Number of attempts: 1
The Quick Brown Fox Jumps Over The Lazy Vim - 404 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: #58 / 190
  • Number of attempts: 3
The name of the game - 654 entries

End up with the name of the game.

  • Best score: 11
  • Best player score: 11
  • Position: #105 / 359
  • Number of attempts: 1
lamb had a little Mary - 596 entries

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

  • Best score: 16
  • Best player score: 17
  • Position: #30 / 164
  • Number of attempts: 7
SFD-ROC: vimvimvim - 1594 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: #23 / 443
  • Number of attempts: 4
Stairs Indenting - 452 entries

Indent each line with <line number> whitespaces.

  • Best score: 12
  • Best player score: 14
  • Position: #96 / 195
  • Number of attempts: 2
Python to Ruby - 198 entries

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

  • Best score: 24
  • Best player score: 37
  • Position: #39 / 60
  • Number of attempts: 3
Saving the hashes(#) - 2008 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: 20
  • Position: #9 / 476
  • Number of attempts: 8
Convert pandoc unordered list to a numbered list - 166 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: 25
  • Position: #28 / 57
  • Number of attempts: 4
Let's play some Ivmgolf - 1096 entries

Oops, I spelled that wrong.

  • Best score: 7
  • Best player score: 9
  • Position: #186 / 442
  • Number of attempts: 2
Vertical Limit - 2487 entries

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

  • Best score: 21
  • Best player score: 24
  • Position: #267 / 748
  • Number of attempts: 2
Aligning function arguments to match a specific coding style - 230 entries

Most projects have specific coding style guidelines. In this case, the argument list must be broken into a new line for each argument, with the argument names right aligned, taking into account pointers.

  • Best score: 16
  • Best player score: 19
  • Position: #40 / 70
  • Number of attempts: 3
Exchanging Quotes - 824 entries

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

  • Best score: 30
  • Best player score: 36
  • Position: #112 / 227
  • Number of attempts: 1
replacing each line of a block selection - 2966 entries

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

  • Best score: 18
  • Best player score: 19
  • Position: #135 / 772
  • Number of attempts: 7
Switch function arguments - 2085 entries

How to switch two arguments of a function.

  • Best score: 11
  • Best player score: 13
  • Position: #356 / 653
  • Number of attempts: 2
Reverse and double space - 498 entries

Reverse the order of the given lines and double space everything

  • Best score: 14
  • Best player score: 14
  • Position: #47 / 197
  • Number of attempts: 4
Remove noise from HTTP log - 700 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: #65 / 272
  • Number of attempts: 4
Remove semicolons after expressions - 639 entries

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

  • Best score: 6
  • Best player score: 6
  • Position: #50 / 261
  • Number of attempts: 2
switch variable - 5045 entries

how fast can you switch two variable ?

  • Best score: 11
  • Best player score: 11
  • Position: #155 / 1742
  • Number of attempts: 1
The meaning - 566 entries

Numbers are fun!

  • Best score: 5
  • Best player score: 5
  • Position: #183 / 360
  • Number of attempts: 1
Sort the cardinal numbers - 294 entries

Maybe a simple challenge.

  • Best score: 12
  • Best player score: 12
  • Position: #36 / 147
  • Number of attempts: 3
Make it more readable - 1955 entries

Insert blank lines to make it more organized and readable

  • Best score: 13
  • Best player score: 13
  • Position: #36 / 643
  • Number of attempts: 7
remove dupes from array - 1345 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: 17
  • Position: #49 / 333
  • Number of attempts: 6
imports alignment (python) - 663 entries

Align as one import per line.

  • Best score: 17
  • Best player score: 20
  • Position: #88 / 196
  • Number of attempts: 5
Rotating Philosophers Problem - 392 entries

Can you help the philosophers find a good place to sit before they get five forks and spaghetti?

  • Best score: 29
  • Best player score: 31
  • Position: #94 / 165
  • Number of attempts: 2
Numbering a List - 1869 entries

Pretty simple, number the list.

  • Best score: 13
  • Best player score: 19
  • Position: #236 / 646
  • Number of attempts: 3
The holy-grail may help - 352 entries

Can you find it in less than 20 strokes, Arthur?

  • Best score: 16
  • Best player score: 16
  • Position: #124 / 207
  • Number of attempts: 2
Ruby 1.9 hashes - 1225 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!

  • Best score: 12
  • Best player score: 12
  • Position: #52 / 402
  • Number of attempts: 4
Assignment Alignment - 842 entries

line up the operators. Use spaces, not tabs.

  • Best score: 18
  • Best player score: 20
  • Position: #85 / 217
  • Number of attempts: 2
Shebangs for all - 1917 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: 14
  • Position: #216 / 502
  • Number of attempts: 2
A Simple One - 1009 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: #325 / 648
  • Number of attempts: 2
Increment, increment, increment.... - 668 entries

Vim likes macros

  • Best score: 10
  • Best player score: 12
  • Position: #262 / 404
  • Number of attempts: 1
The Cake is a Lie - 1301 entries

Correct the capitalization of each word

  • Best score: 9
  • Best player score: 9
  • Position: #145 / 517
  • Number of attempts: 3
Make Fancy Header - 1024 entries

Make the header text stand out with surrounding asterisks

  • Best score: 15
  • Best player score: 16
  • Position: #74 / 340
  • Number of attempts: 3
Reformat some Python - 590 entries

Fix some very bizarrely laid-out code.

  • Best score: 34
  • Best player score: 40
  • Position: #89 / 233
  • Number of attempts: 1
Reverse characters in a line - 732 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: 14
  • Position: #96 / 257
  • Number of attempts: 2
Remember FizzBuzz? - 686 entries

Output FizzBuzz to 100. Start with nothing.

  • Best score: 39
  • Best player score: 49
  • Position: #39 / 184
  • Number of attempts: 5
Get rid of html tags - 378 entries

Want to read more about Vim's background? Then get rid of those html tags...

  • Best score: 15
  • Best player score: 17
  • Position: #87 / 222
  • Number of attempts: 1
Change the content of a string - 1502 entries

This docstring is a complete lie. Fix it.

  • Best score: 22
  • Best player score: 22
  • Position: #110 / 567
  • Number of attempts: 1
Sort and add attributes - 1369 entries

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

  • Best score: 33
  • Best player score: 33
  • Position: #135 / 542
  • Number of attempts: 4
Add fold markers to a .c file - 571 entries

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

  • Best score: 30
  • Best player score: 37
  • Position: #124 / 175
  • Number of attempts: 1
Reconstruct the Sentence - 1436 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: 21
  • Position: #200 / 397
  • Number of attempts: 2
Braces or Brackets? - 930 entries

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

  • Best score: 34
  • Best player score: 41
  • Position: #102 / 295
  • Number of attempts: 3
Whitespace, empty lines and tabs - 3508 entries

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

  • Best score: 16
  • Best player score: 17
  • Position: #85 / 758
  • Number of attempts: 6
Flodder-challenge - 1176 entries

Replace the text the most efficient and win!

  • Best score: 27
  • Best player score: 28
  • Position: #62 / 321
  • Number of attempts: 6
Simple text editing with Vim - 12491 entries

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

  • Best score: 13
  • Best player score: 13
  • Position: #121 / 3626
  • Number of attempts: 10
Reformat/Refactor a Golfer Class - 6749 entries

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

  • Best score: 31
  • Best player score: 33
  • Position: #225 / 1652
  • Number of attempts: 6
Steve Tjoa
Twitter:

Software engineer @google. For fun: https://t.co/whYGJUxh9O

entered into 101 challenges

contributed 0 challenges