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

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: 78
  • Number of attempts: 2
Execute immediate SQL - 77 entries

Sql string tranformation ...

  • Best score: 60
  • Best player score: 73
  • Number of attempts: 2
Draw the Go board - 110 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
  • Number of attempts: 2
remove dupes from array - 1220 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
  • Number of attempts: 6
Get rid of html tags - 315 entries

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

  • Best score: 15
  • Best player score: 17
  • Number of attempts: 1
Whitespace, empty lines and tabs - 2589 entries

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

  • Best score: 16
  • Best player score: 17
  • Number of attempts: 6
I forgot quotes - 12685 entries

Oops.

  • Best score: 10
  • Best player score: 16
  • Number of attempts: 1
Count both ways - 887 entries

Right AND down.

  • Best score: 13
  • Best player score: 16
  • Number of attempts: 3
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: 28
  • Number of attempts: 2
LaTeX to XML Math Delimiters - 35 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
  • Number of attempts: 2
Number an outline - 199 entries

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

  • Best score: 25
  • Best player score: 66
  • Number of attempts: 1
Enumerate words - 223 entries

Enumerate the unique words in order.

  • Best score: 23
  • Best player score: 26
  • Number of attempts: 3
Create Leading Zeros - 192 entries

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

  • Best score: 23
  • Best player score: 43
  • Number of attempts: 1
quotes inside quotes - 2833 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
  • Number of attempts: 2
vim = 22 / 7 - 398 entries

pi square vim

  • Best score: 20
  • Best player score: 20
  • Number of attempts: 2
The meaning - 503 entries

Numbers are fun!

  • Best score: 5
  • Best player score: 5
  • Number of attempts: 1
A Simple One - 849 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: 2
REDRUM - 136 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
  • Number of attempts: 4
Recursive Cowsay - 49 entries

Convert 'cowsay' statement to recursive output

  • Best score: 33
  • Best player score: 40
  • Number of attempts: 10
Make Fancy Header - 921 entries

Make the header text stand out with surrounding asterisks

  • Best score: 16
  • Best player score: 16
  • Number of attempts: 3
Words in parens - 11357 entries

We should all ace this, right?

  • Best score: 14
  • Best player score: 14
  • Number of attempts: 8
Assign list - 145 entries

Assign list elements to matrix

  • Best score: 30
  • Best player score: 32
  • Number of attempts: 5
Add fold markers to a .c file - 443 entries

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

  • Best score: 30
  • Best player score: 37
  • Number of attempts: 1
Shebangs for all - 1632 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
  • Number of attempts: 2
Make it more readable - 1765 entries

Insert blank lines to make it more organized and readable

  • Best score: 13
  • Best player score: 13
  • Number of attempts: 7
SFD-ROC: vimvimvim - 1305 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: 4
Delete unwanted lines - 339 entries

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

  • Best score: 9
  • Best player score: 9
  • Number of attempts: 1
Going underground.... - 291 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: 4
The Quick Brown Fox Jumps Over The Lazy Vim - 330 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: 3
Condensed Cases - 698 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
  • Number of attempts: 4
SFD-ROC: The Quick Brown Fox - 140 entries

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

  • Best score: 25
  • Best player score: 28
  • Number of attempts: 1
-a-b-c- - 2689 entries

Put hyphens everywhere.

  • Best score: 13
  • Best player score: 16
  • Number of attempts: 1
Stairs Indenting - 360 entries

Indent each line with <line number> whitespaces.

  • Best score: 12
  • Best player score: 14
  • Number of attempts: 2
Let's play some Ivmgolf - 937 entries

Oops, I spelled that wrong.

  • Best score: 7
  • Best player score: 9
  • Number of attempts: 2
Remove semicolons after expressions - 463 entries

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

  • Best score: 6
  • Best player score: 6
  • Number of attempts: 2
Word frequency alignment - 198 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
  • Number of attempts: 1
Collect List - 3603 entries

Convert to comma separated list.

  • Best score: 12
  • Best player score: 15
  • Number of attempts: 1
The Cake is a Lie - 1139 entries

Correct the capitalization of each word

  • Best score: 9
  • Best player score: 9
  • Number of attempts: 3
Sort the VimGolf challenges by popularity - 268 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: 3
A HAPPY NEW YEAR 2014 ! - 9706 entries

A HAPPY NEW YEAR 2014 !

  • Best score: 11
  • Best player score: 12
  • Number of attempts: 1
Simple text editing with Vim - 10650 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: 10
Sort the cardinal numbers - 221 entries

Maybe a simple challenge.

  • Best score: 12
  • Best player score: 12
  • Number of attempts: 3
Wrap the text of an email message to 79 characters - 495 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
Swap assigned value - 499 entries

Simple problem but looking for interesting solutions.

  • Best score: 10
  • Best player score: 10
  • Number of attempts: 2
switch variable - 4437 entries

how fast can you switch two variable ?

  • Best score: 11
  • Best player score: 11
  • Number of attempts: 1
The name of the game - 587 entries

End up with the name of the game.

  • Best score: 11
  • Best player score: 11
  • Number of attempts: 1
Increment, increment, increment.... - 493 entries

Vim likes macros

  • Best score: 10
  • Best player score: 12
  • Number of attempts: 1
Counting in binary - 393 entries

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

  • Best score: 16
  • Best player score: 22
  • Number of attempts: 1
abcd > a b c d - 241 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 - 1450 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: 2
Ruby 1.9 hashes - 1080 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
  • Number of attempts: 4
Switch function arguments - 1850 entries

How to switch two arguments of a function.

  • Best score: 11
  • Best player score: 13
  • Number of attempts: 2
Reverse characters in a line - 585 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
  • Number of attempts: 2
Vertical Limit - 2163 entries

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

  • Best score: 21
  • Best player score: 24
  • Number of attempts: 2
Hanging Indent for Footnotes - 58 entries

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

  • Best score: 17
  • Best player score: 23
  • 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
Mirror Symmetry - 716 entries

Add backslashes.

  • Best score: 7
  • Best player score: 7
  • Number of attempts: 2
Change the content of a string - 1250 entries

This docstring is a complete lie. Fix it.

  • Best score: 22
  • Best player score: 22
  • Number of attempts: 1
VimGolfNight - 458 entries

Based on "The name of the game".

  • Best score: 12
  • Best player score: 12
  • Number of attempts: 2
Convert pandoc unordered list to a numbered list - 136 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
  • Number of attempts: 4
Prefixes and suffixes - 506 entries

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

  • Best score: 17
  • Best player score: 26
  • Number of attempts: 1
Remember FizzBuzz? - 537 entries

Output FizzBuzz to 100. Start with nothing.

  • Best score: 39
  • Best player score: 49
  • Number of attempts: 5
lamb had a little Mary - 499 entries

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

  • Best score: 16
  • Best player score: 17
  • Number of attempts: 7
Untangle my tail, please! - 44 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
  • Number of attempts: 1
Groups magic - 136 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: 1
Hole-in-one - 941 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
  • Number of attempts: 2
Remove noise from HTTP log - 618 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: 4
Reconstruct the Sentence - 1028 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
  • Number of attempts: 2
Pretty format for variable declarations - 128 entries

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

  • Best score: 14
  • Best player score: 18
  • Number of attempts: 2
Numbering a List - 1747 entries

Pretty simple, number the list.

  • Best score: 13
  • Best player score: 19
  • Number of attempts: 3
Search and Replace 0 - 4205 entries

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

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

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

  • Best score: 18
  • Best player score: 19
  • Number of attempts: 7
Reverse and double space - 411 entries

Reverse the order of the given lines and double space everything

  • Best score: 14
  • Best player score: 14
  • Number of attempts: 4
Saving the hashes(#) - 1794 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
  • Number of attempts: 8
Aligning function arguments to match a specific coding style - 159 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
  • Number of attempts: 3
NATO phonetic alphabet - 407 entries

Transform the series of words into a list.

  • Best score: 19
  • Best player score: 19
  • Number of attempts: 5
Assignment Alignment - 700 entries

line up the operators. Use spaces, not tabs.

  • Best score: 18
  • Best player score: 20
  • Number of attempts: 2
Lookahead and Lookbehind - 65 entries

Look everywhere

  • Best score: 16
  • Best player score: 20
  • Number of attempts: 3
Reformat/Refactor a Golfer Class - 5569 entries

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

  • Best score: 32
  • Best player score: 33
  • Number of attempts: 6
Block Fun 1 - 158 entries

Manipulate the columns to produce desired result.

  • Best score: 14
  • Best player score: 21
  • Number of attempts: 1
Reformat some Python - 511 entries

Fix some very bizarrely laid-out code.

  • Best score: 34
  • Best player score: 40
  • Number of attempts: 1
Parsing with CSV: Unify lines and result. - 162 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
  • Number of attempts: 1
Coordinates placeholder - 52 entries

Place coordinates instead of target search.

  • Best score: 22
  • Best player score: 26
  • Number of attempts: 1
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: 40
  • Number of attempts: 1
Pairs of numbers - 325 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
  • Number of attempts: 3
Readable Rubyhash - 232 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
  • Number of attempts: 1
Flodder-challenge - 814 entries

Replace the text the most efficient and win!

  • Best score: 27
  • Best player score: 28
  • Number of attempts: 6
Sort by sum of numbers in a line(?) - 45 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
  • Number of attempts: 1
imports alignment (python) - 577 entries

Align as one import per line.

  • Best score: 17
  • Best player score: 20
  • Number of attempts: 5
Two become one - 676 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
  • Number of attempts: 5
attr_aligner - 3075 entries

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

  • Best score: 19
  • Best player score: 30
  • Number of attempts: 2
Minimalist Limerick - 481 entries

Reproduce this lovely poem.

  • Best score: 31
  • Best player score: 33
  • Number of attempts: 3
The holy-grail may help - 301 entries

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

  • Best score: 16
  • Best player score: 16
  • Number of attempts: 2
Rotating Philosophers Problem - 358 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
  • Number of attempts: 2
Top X - 181 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
  • Number of attempts: 6
Change your calendar - 263 entries

Happy New Year!

  • Best score: 18
  • Best player score: 31
  • Number of attempts: 2
Sort and add attributes - 1096 entries

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

  • Best score: 33
  • Best player score: 33
  • Number of attempts: 4
Mess in revision history - 1001 entries

Help Joe clean up what Steve has cobbled.

  • Best score: 17
  • Best player score: 33
  • Number of attempts: 2
Exchanging Quotes - 761 entries

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

  • Best score: 30
  • Best player score: 36
  • Number of attempts: 1
Python to Ruby - 188 entries

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

  • Best score: 24
  • Best player score: 37
  • Number of attempts: 3
Braces or Brackets? - 627 entries

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

  • Best score: 34
  • Best player score: 41
  • Number of attempts: 3
Steve Tjoa
Twitter:

Data scientist @ayzenberg, machine learning. Stanford @ccrma workshop instructor, music information retrieval. "This Twitter account is great!" ~Elon Musk

entered into 101 challenges

contributed 0 challenges