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

pi square vim

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

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

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

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

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

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

  • Best score: 23
  • Best player score: 43
  • Position: #54 / 82
  • 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 - 822 entries

Add backslashes.

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

Simple problem but looking for interesting solutions.

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

Happy New Year!

  • Best score: 18
  • Best player score: 31
  • Position: #42 / 87
  • Number of attempts: 2
Collect List - 4298 entries

Convert to comma separated list.

  • Best score: 12
  • Best player score: 15
  • Position: #670 / 1190
  • Number of attempts: 1
VimGolfNight - 560 entries

Based on "The name of the game".

  • Best score: 12
  • Best player score: 12
  • Position: #32 / 347
  • Number of attempts: 2
Condensed Cases - 804 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: #108 / 247
  • Number of attempts: 4
Pretty format for variable declarations - 170 entries

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

  • Best score: 13
  • Best player score: 18
  • Position: #43 / 64
  • Number of attempts: 2
I forgot quotes - 15977 entries

Oops.

  • Best score: 10
  • Best player score: 16
  • Position: #2387 / 4177
  • Number of attempts: 1
-a-b-c- - 3213 entries

Put hyphens everywhere.

  • Best score: 13
  • Best player score: 16
  • Position: #760 / 1137
  • Number of attempts: 1
Count both ways - 1022 entries

Right AND down.

  • Best score: 13
  • Best player score: 16
  • Position: #148 / 354
  • 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.... - 350 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 - 363 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: #70 / 110
  • Number of attempts: 1
A HAPPY NEW YEAR 2014 ! - 10658 entries

A HAPPY NEW YEAR 2014 !

  • Best score: 11
  • Best player score: 12
  • Position: #1627 / 3680
  • Number of attempts: 1
attr_aligner - 3511 entries

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

  • Best score: 19
  • Best player score: 30
  • Position: #354 / 698
  • Number of attempts: 2
Ninjas Leaderboard - 99 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: #21 / 41
  • Number of attempts: 1
Counting in binary - 526 entries

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

  • Best score: 16
  • Best player score: 22
  • Position: #35 / 117
  • Number of attempts: 1
Letter case trickery - 1630 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: #182 / 518
  • Number of attempts: 2
Untangle my tail, please! - 60 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 / 33
  • Number of attempts: 1
quotes inside quotes - 3159 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: #518 / 1078
  • Number of attempts: 2
Hanging Indent for Footnotes - 72 entries

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

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

Convert 'cowsay' statement to recursive output

  • Best score: 33
  • Best player score: 40
  • Position: #8 / 19
  • Number of attempts: 10
Top X - 212 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: #11 / 71
  • Number of attempts: 6
Sort the VimGolf challenges by popularity - 348 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 / 107
  • Number of attempts: 3
Number an outline - 280 entries

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

  • Best score: 25
  • Best player score: 66
  • Position: #59 / 78
  • Number of attempts: 1
Words in parens - 12929 entries

We should all ace this, right?

  • Best score: 13
  • Best player score: 14
  • Position: #33 / 3961
  • Number of attempts: 8
Pairs of numbers - 363 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 / 136
  • Number of attempts: 3
Assign list - 192 entries

Assign list elements to matrix

  • Best score: 30
  • Best player score: 32
  • Position: #13 / 61
  • Number of attempts: 5
Draw the Go board - 149 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 / 51
  • Number of attempts: 2
Hole-in-one - 1018 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 / 304
  • Number of attempts: 2
Delete unwanted lines - 411 entries

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

  • Best score: 9
  • Best player score: 9
  • Position: #9 / 229
  • Number of attempts: 1
Parsing with CSV: Unify lines and result. - 179 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 / 77
  • Number of attempts: 1
Lookahead and Lookbehind - 70 entries

Look everywhere

  • Best score: 16
  • Best player score: 20
  • Position: #12 / 31
  • Number of attempts: 3
Word frequency alignment - 290 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 / 161
  • Number of attempts: 1
LaTeX to XML Math Delimiters - 48 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 / 20
  • Number of attempts: 2
Minimalist Limerick - 520 entries

Reproduce this lovely poem.

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

Place coordinates instead of target search.

  • Best score: 22
  • Best player score: 26
  • Position: #27 / 38
  • Number of attempts: 1
Define to require - 127 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 / 50
  • Number of attempts: 2
REDRUM - 164 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 / 64
  • Number of attempts: 4
Enumerate words - 254 entries

Enumerate the unique words in order.

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

Sql string tranformation ...

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

Manipulate the columns to produce desired result.

  • Best score: 14
  • Best player score: 21
  • Position: #35 / 75
  • Number of attempts: 1
Groups magic - 158 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 / 93
  • Number of attempts: 1
Prefixes and suffixes - 629 entries

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

  • Best score: 17
  • Best player score: 26
  • Position: #80 / 196
  • Number of attempts: 1
Sort by sum of numbers in a line(?) - 67 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: #27 / 39
  • Number of attempts: 1
abcd > a b c d - 291 entries

transform the single spaces into 4 spaces repeat for each line

  • Best score: 15
  • Best player score: 15
  • Position: #68 / 222
  • Number of attempts: 1
Readable Rubyhash - 267 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: #53 / 95
  • Number of attempts: 1
NATO phonetic alphabet - 526 entries

Transform the series of words into a list.

  • Best score: 19
  • Best player score: 19
  • Position: #8 / 195
  • Number of attempts: 5
SFD-ROC: The Quick Brown Fox - 193 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: #66 / 106
  • Number of attempts: 1
The Quick Brown Fox Jumps Over The Lazy Vim - 416 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: #59 / 191
  • Number of attempts: 3
The name of the game - 665 entries

End up with the name of the game.

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

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

  • Best score: 16
  • Best player score: 17
  • Position: #30 / 166
  • Number of attempts: 7
SFD-ROC: vimvimvim - 1606 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 / 446
  • Number of attempts: 4
Stairs Indenting - 473 entries

Indent each line with <line number> whitespaces.

  • Best score: 12
  • Best player score: 14
  • Position: #97 / 197
  • Number of attempts: 2
Python to Ruby - 204 entries

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

  • Best score: 24
  • Best player score: 37
  • Position: #39 / 61
  • Number of attempts: 3
Saving the hashes(#) - 2063 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 / 480
  • 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 - 1118 entries

Oops, I spelled that wrong.

  • Best score: 7
  • Best player score: 9
  • Position: #188 / 445
  • Number of attempts: 2
Vertical Limit - 2538 entries

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

  • Best score: 21
  • Best player score: 24
  • Position: #273 / 754
  • Number of attempts: 2
Aligning function arguments to match a specific coding style - 247 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: #41 / 71
  • Number of attempts: 3
Exchanging Quotes - 858 entries

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

  • Best score: 30
  • Best player score: 36
  • Position: #113 / 230
  • Number of attempts: 1
replacing each line of a block selection - 2999 entries

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

  • Best score: 18
  • Best player score: 19
  • Position: #137 / 777
  • Number of attempts: 7
Switch function arguments - 2130 entries

How to switch two arguments of a function.

  • Best score: 11
  • Best player score: 13
  • Position: #363 / 661
  • Number of attempts: 2
Reverse and double space - 500 entries

Reverse the order of the given lines and double space everything

  • Best score: 14
  • Best player score: 14
  • Position: #47 / 199
  • Number of attempts: 4
Remove noise from HTTP log - 717 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 / 273
  • Number of attempts: 4
Remove semicolons after expressions - 654 entries

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

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

how fast can you switch two variable ?

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

Numbers are fun!

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

Maybe a simple challenge.

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

Insert blank lines to make it more organized and readable

  • Best score: 13
  • Best player score: 13
  • Position: #36 / 649
  • Number of attempts: 7
remove dupes from array - 1354 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 / 335
  • Number of attempts: 6
imports alignment (python) - 700 entries

Align as one import per line.

  • Best score: 17
  • Best player score: 20
  • Position: #89 / 198
  • Number of attempts: 5
Rotating Philosophers Problem - 410 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: #95 / 166
  • Number of attempts: 2
Numbering a List - 1931 entries

Pretty simple, number the list.

  • Best score: 13
  • Best player score: 19
  • Position: #240 / 652
  • Number of attempts: 3
The holy-grail may help - 362 entries

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

  • Best score: 16
  • Best player score: 16
  • Position: #124 / 208
  • Number of attempts: 2
Ruby 1.9 hashes - 1244 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 / 406
  • Number of attempts: 4
Assignment Alignment - 883 entries

line up the operators. Use spaces, not tabs.

  • Best score: 18
  • Best player score: 20
  • Position: #86 / 220
  • Number of attempts: 2
Shebangs for all - 1998 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: #222 / 515
  • Number of attempts: 2
A Simple One - 1047 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 / 662
  • Number of attempts: 2
Increment, increment, increment.... - 684 entries

Vim likes macros

  • Best score: 10
  • Best player score: 12
  • Position: #263 / 406
  • Number of attempts: 1
The Cake is a Lie - 1339 entries

Correct the capitalization of each word

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

Make the header text stand out with surrounding asterisks

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

Fix some very bizarrely laid-out code.

  • Best score: 34
  • Best player score: 40
  • Position: #90 / 235
  • Number of attempts: 1
Reverse characters in a line - 757 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: #99 / 263
  • Number of attempts: 2
Remember FizzBuzz? - 713 entries

Output FizzBuzz to 100. Start with nothing.

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

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

  • Best score: 12
  • Best player score: 17
  • Position: #89 / 228
  • Number of attempts: 1
Change the content of a string - 1567 entries

This docstring is a complete lie. Fix it.

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

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

  • Best score: 33
  • Best player score: 33
  • Position: #135 / 559
  • Number of attempts: 4
Add fold markers to a .c file - 608 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: #128 / 181
  • Number of attempts: 1
Reconstruct the Sentence - 1487 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: #203 / 409
  • Number of attempts: 2
Braces or Brackets? - 969 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: #105 / 312
  • Number of attempts: 3
Whitespace, empty lines and tabs - 3614 entries

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

  • Best score: 16
  • Best player score: 17
  • Position: #88 / 780
  • Number of attempts: 6
Flodder-challenge - 1237 entries

Replace the text the most efficient and win!

  • Best score: 27
  • Best player score: 28
  • Position: #64 / 333
  • Number of attempts: 6
Simple text editing with Vim - 12744 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 / 3681
  • Number of attempts: 10
Reformat/Refactor a Golfer Class - 6937 entries

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

  • Best score: 28
  • Best player score: 33
  • Position: #227 / 1699
  • Number of attempts: 6
Steve Tjoa
Twitter:

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

entered into 101 challenges

contributed 0 challenges