Real Vim ninjas count every keystroke - do you?

Pick a challenge, fire up Vim, and show us what you got.

Leaderboard, Changelog, Rules & FAQ, updates: @vimgolf, RSS.

Your VimGolf key: please sign in

$ gem install vimgolf
$ vimgolf setup
$ vimgolf put [challenge ID]

Top Entries

Assignment Alignment - Rank: 1/414, Score: 18

line up the operators. Use spaces, not tabs.

Another Mixed-Up Haiku - Rank: 1/148, Score: 21

VimGolf ... a perfect evening?

Whitespace, empty lines and tabs - Rank: 1/971, Score: 15

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

Getters & Setters: Java - Rank: 1/100, Score: 92

Boilerplate getters & setters - it's a tedious fact of life in Java, and probably the only thing that still pulls me back to an IDE. Perhaps someone knows a fast, pure vim way...

Remove Accent off the Letter - Rank: 1/75, Score: 38

Remove all the accent from extremely accented statements.

Reformat most common surnames - Rank: 2/275, Score: 25

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

CSV to JSON - Rank: 2/113, Score: 60

A search for shortest vimissh way to convert CSV to JSON.

Sort the cardinal numbers - Rank: 2/142, Score: 12

Maybe a simple challenge.

Generate Fibonacci Numbers - Rank: 2/132, Score: 19

Use your super vim powers to generate Fibonacci Numbers.

Return the cow - Rank: 2/68, Score: 41

This cow is too verbose. Give it a lesson.

Align it, win it. - Rank: 2/141, Score: 32

Align this simple listing.

Before there was Farmville... - Rank: 2/54, Score: 165

There was old MacDonald. For my toddler. The first Vim sing-a-long?

Make Vim ASCII Art - Rank: 3/26, Score: 139

Art is the triumph over chaos. ~John Cheever

Braces or Brackets? - Rank: 3/354, Score: 34

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

Sorting paragraphs - Rank: 3/274, Score: 21

Order the paragraphs correctly, per prefixed index

Overall Vimgolf Rank - Rank: 3/99, Score: 24

Suppose you are trying to figure out what your overall rank is at Vimgolf(the sum of all the ranks you got), and as a Vim ninja you decided to use Vim to do the job. Your solution should work for every Vimgolf profile page(The actual input file for this challenge is my Vimgolf profile page). So, direct answer insertion is considered cheating.

It'ss tooo coold too typpe todaay - Rank: 3/152, Score: 16

My hands are numb with cold. It's hard to type correctly.

Deleting folded text - Rank: 3/160, Score: 19

The text below contains three folds. Delete them (and the text inside them). For example: 123 456 /*{{{*/ 789 /*}}}*/ 012 Should become: 123 012 Also, add `aoeuaoeu` to make sure small solutions don't get flagged as cheating.

Add fold markers to a .c file - Rank: 3/235, Score: 30

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

Linear congruential generator - Rank: 3/74, Score: 30

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

Cartesian product - Rank: 3/142, Score: 26

{1,2,3,4,5} X {1,2,3,4,5}

Reverse Simple Deletion - Rank: 3/365, Score: 12

You did the simple deletion, now reverse it.

Rotating Philosophers Problem - Rank: 4/271, Score: 29

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

82 bottles of beer on the wall - Rank: 4/194, Score: 109

Take them down. (sorry, only 82 bottles because the problem size is limited!)

Ruby 1.9 hashes - Rank: 4/541, Score: 12

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!

Fix the Haiku - Rank: 4/160, Score: 30

Change this slightly scrambled haiku to its unscrambled form and fix the capitalisation and punctuation along the way.

Word Blender - Rank: 4/90, Score: 34

The insides of long words seem to have been run through the blender. Can you fix this famous tale, brave knight?

Happy New Year! - Rank: 4/96, Score: 24

This is a simple new year's challenge.

Prime Numbers - Rank: 4/115, Score: 34

List the first 100 prime numbers.

fix typos, reformat and refactor an ActiveRecord model. - Rank: 4/64, Score: 105

Simple case of refactoring ruby code, change camelize word to undescored (vice versa), proper indentation, removing trailing white spaces, etc.

Reformat long lines - Rank: 4/229, Score: 15

Rearrange this ruby method call to put each parameter on its own line. Could become a useful macro.

Java Array2List - Rank: 4/161, Score: 77

Convert an java array initializer into a list.

HTML to Haml - Rank: 4/432, Score: 27

Help convert this HTML page to Haml.

Here, piggy, piggy... - Rank: 4/55, Score: 77

Youay owknay atwhay otay oday...

A Simple One - Rank: 5/524, Score: 9

Here is a very simple one - just to illustrate/introduce a vim feature that some people seem to miss...

Promote that perl 'one-liner' ... - Rank: 5/103, Score: 92

You've just sorted your data using perl -e, when suddenly you have to add a row and do it again. That's twice - you'll almost certainly do it again. Time to turn it into a real script. We'll start from having pasted it in ...

expand a list comprehension (python) - Rank: 5/188, Score: 42

Please show your way to convert a list comprehension in python to an ordinary for-loop expression!

Dumb to smart - Rank: 5/61, Score: 29

Turn dumb quote to smart vim's way.

The Universal Declaration of Human Rights, Article 1 - Rank: 5/110, Score: 24

Somebody's got this slightly muddled up. See how quickly you can fix it. (I made this to experiment with buffers. I'm not actually sure whether this is faster with buffers or without.)

Hatsuyume - Rank: 5/271, Score: 15

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

Simple text editing with Vim - Rank: 5/2549, Score: 13

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

Generate English Alphabets - Rank: 5/254, Score: 24

Start with a, get up to z.

Reverse a single line - Rank: 5/491, Score: 9

Reverse a single line vertically.

Flodder-challenge - Rank: 5/356, Score: 28

Replace the text the most efficient and win!

Round Round - Rank: 6/139, Score: 23

Round Round

Reformat some Python - Rank: 6/323, Score: 34

Fix some very bizarrely laid-out code.

Remember FizzBuzz? - Rank: 6/247, Score: 50

Output FizzBuzz to 100. Start with nothing.

Letters are numbers - Rank: 6/87, Score: 26

Letters and numbers are interchangeable. A lot of programming languages give you simple ways to convert individual letters to hex, binary and decimal but does Vim?

Shebangs for all - Rank: 7/605, Score: 12

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.

Complete the hex array data (Part II) - Rank: 8/88, Score: 22

Do not use external tools(e.g. tac, seq) [My interpretation of Rule #7]

Compile C - Rank: 8/336, Score: 11

You might have to get clever to do this one.

Turn this csv list into queries - Rank: 8/135, Score: 106

Transform each line of this csv file into a MySQL-ready INSERT query.

Case preserving word replacement - Rank: 8/282, Score: 19

Half way through my project, my people turned into dogs. Now I have to change everything in my source.

Reconstruct the Sentence - Rank: 9/524, Score: 20

Get the sentence back in the proper order, remove duplicate lines, and then combine the separate lines into one.

Complete the hex array data - Rank: 9/135, Score: 25

Do not use external tools(e.g. tac, seq) [My interpretation of Rule #7]

PEP8 Python Wrapping Comments and Code - Rank: 9/113, Score: 26

According to PEP8, long flowy text and code should have different max line lengths. Code: 79 characters max Long flowy text: 72 characters max

Solve the Sokoban - Rank: 9/113, Score: 30

A wink for all Vimgolfers that play Nethack too.

Insert a Markdown link - Rank: 10/309, Score: 23

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

Ruby 1.9 compat - Rank: 10/382, Score: 14

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!

imports alignment (python) - Rank: 11/356, Score: 17

Align as one import per line.

Reformat a C golf submission - Rank: 12/303, Score: 22

Take this C golf submission (for the "tiny but standards-compliant Hello World program" category, naturally), and turn it into formatted C code.

Interweave two blocks of text - Rank: 13/207, Score: 17

Suppose you've got data on a list of things from multiple sources. They're all in separate chunks, so how might you create a tabular output?

Increment, increment, increment.... - Rank: 13/270, Score: 11

Vim likes macros

Table Reshuffle - Rank: 14/213, Score: 24

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

Indentation - Rank: 15/290, Score: 23

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

The holy-grail may help - Rank: 15/210, Score: 16

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

Remove duplicate items - Rank: 16/293, Score: 12

Input is a list of numbers. Produce a set of unique numbers from input.

Wrap the text of an email message to 79 characters - Rank: 17/275, Score: 5

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

Recursively Palindrome - Rank: 18/150, Score: 24

Note that there are 2^6-1 characters.

Almost encrypted - Rank: 18/124, Score: 5

Convert the first paragraph to be even less readable.

Vim manuals written by Bram. - Rank: 19/57, Score: 52

Find Vim reference manuals written by Bram Moolenaar.

Python Hello World! Reformatting - Rank: 20/443, Score: 41

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.

Change the content of a string - Rank: 21/564, Score: 22

This docstring is a complete lie. Fix it.

Make Fancy Header - Rank: 24/517, Score: 16

Make the header text stand out with surrounding asterisks

Reverse characters in a line - Rank: 26/450, Score: 8

You have everything you need, just not in the right order. Mastermind would give you 26 white pegs.

The Cake is a Lie - Rank: 28/570, Score: 9

Correct the capitalization of each word

Reverse and count - Rank: 29/341, Score: 23

Someone typed things upside down and now a Vim ninja needs to reverse the lines and count how many there are.

Context insensitive completion 0 - Rank: 29/306, Score: 7

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.

Numbering a List - Rank: 32/832, Score: 19

Pretty simple, number the list.

Do you have a big gun? - Rank: 33/160, Score: 5

Of course I have.

Sort and add attributes - Rank: 39/595, Score: 33

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

Get rid of html tags - Rank: 39/194, Score: 17

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

Context Insensitive completion 1 - Rank: 45/267, Score: 18

Finish writing this simple Python HTTP server.

Search and Replace 0 - Rank: 70/1256, Score: 12

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

Reformat/Refactor a Golfer Class - Rank: 97/1924, Score: 36

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

Contributed Challenges

Overall Vimgolf Rank - 99 entries

Suppose you are trying to figure out what your overall rank is at Vimgolf(the sum of all the ranks you got), and as a Vim ninja you decided to use Vim to do the job. Your solution should work for every Vimgolf profile page(The actual input file for this challenge is my Vimgolf profile page). So, direct answer insertion is considered cheating.

Me-small_normal
Wei Dai
Twitter:

entered into 85 challenges

contributed 1 challenges