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

Prime Numbers - 354 entries

List the first 100 prime numbers.

  • Best score: 34
  • Best player score: 43
  • Position: #34 / 104
  • Number of attempts: 12
Word Blender - 148 entries

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

  • Best score: 28
  • Best player score: 34
  • Position: #9 / 57
  • Number of attempts: 4
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: #17 / 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: #68 / 1621
  • Number of attempts: 6
Interweave two blocks of text - 659 entries

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?

  • Best score: 15
  • Best player score: 17
  • Position: #69 / 214
  • Number of attempts: 1
Python Hello World! Reformatting - 989 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: 41
  • Position: #44 / 379
  • Number of attempts: 4
Cartesian product - 255 entries

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

  • Best score: 24
  • Best player score: 26
  • Position: #13 / 95
  • Number of attempts: 4
Recursively Palindrome - 267 entries

Note that there are 2^6-1 characters.

  • Best score: 21
  • Best player score: 24
  • Position: #37 / 75
  • Number of attempts: 1
Exchanging Quotes - 858 entries

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

  • Best score: 30
  • Best player score: 31
  • Position: #24 / 230
  • Number of attempts: 7
replacing each line of a block selection - 2999 entries

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

  • Best score: 18
  • Best player score: 18
  • Position: #38 / 777
  • Number of attempts: 5
Switch function arguments - 2130 entries

How to switch two arguments of a function.

  • Best score: 11
  • Best player score: 11
  • Position: #24 / 661
  • Number of attempts: 3
Append semicolon after expressions - 1054 entries

Some lines need the semicolon, some don't.

  • Best score: 11
  • Best player score: 11
  • Position: #15 / 418
  • Number of attempts: 4
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: #34 / 199
  • Number of attempts: 4
switch variable - 5071 entries

how fast can you switch two variable ?

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

Numbers are fun!

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

Maybe a simple challenge.

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

Insert blank lines to make it more organized and readable

  • Best score: 13
  • Best player score: 13
  • Position: #23 / 649
  • Number of attempts: 5
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: #38 / 335
  • Number of attempts: 6
Complete the hex array data - 197 entries

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

  • Best score: 23
  • Best player score: 25
  • Position: #17 / 74
  • Number of attempts: 3
Case preserving word replacement - 454 entries

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

  • Best score: 19
  • Best player score: 19
  • Position: #8 / 180
  • Number of attempts: 1
Complete the hex array data (Part II) - 166 entries

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

  • Best score: 20
  • Best player score: 22
  • Position: #10 / 69
  • Number of attempts: 1
Here, piggy, piggy... - 80 entries

Youay owknay atwhay otay oday...

  • Best score: 68
  • Best player score: 77
  • Position: #9 / 23
  • Number of attempts: 4
Happy New Year! - 145 entries

This is a simple new year's challenge.

  • Best score: 22
  • Best player score: 24
  • Position: #11 / 59
  • Number of attempts: 2
imports alignment (python) - 700 entries

Align as one import per line.

  • Best score: 17
  • Best player score: 17
  • Position: #11 / 198
  • Number of attempts: 1
Generate Fibonacci Numbers - 280 entries

Use your super vim powers to generate Fibonacci Numbers.

  • Best score: 19
  • Best player score: 19
  • Position: #2 / 100
  • Number of attempts: 4
It'ss tooo coold too typpe todaay - 222 entries

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

  • Best score: 16
  • Best player score: 16
  • Position: #2 / 97
  • Number of attempts: 4
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: 29
  • Position: #4 / 166
  • Number of attempts: 3
Before there was Farmville... - 101 entries

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

  • Best score: 156
  • Best player score: 165
  • Position: #8 / 49
  • Number of attempts: 5
HTML to Haml - 878 entries

Help convert this HTML page to Haml.

  • Best score: 23
  • Best player score: 27
  • Position: #22 / 204
  • Number of attempts: 1
expand a list comprehension (python) - 333 entries

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

  • Best score: 42
  • Best player score: 42
  • Position: #5 / 109
  • Number of attempts: 2
Reformat long lines - 358 entries

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

  • Best score: 15
  • Best player score: 15
  • Position: #4 / 134
  • Number of attempts: 3
Generate English Alphabets - 487 entries

Start with a, get up to z.

  • Best score: 19
  • Best player score: 24
  • Position: #28 / 206
  • Number of attempts: 3
Overall Vimgolf Rank - 216 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.

  • Best score: 21
  • Best player score: 24
  • Position: #9 / 59
  • Number of attempts: 2
Insert a Markdown link - 434 entries

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

  • Best score: 22
  • Best player score: 23
  • Position: #17 / 145
  • Number of attempts: 4
Numbering a List - 1931 entries

Pretty simple, number the list.

  • Best score: 13
  • Best player score: 19
  • Position: #153 / 652
  • Number of attempts: 1
The Universal Declaration of Human Rights, Article 1 - 163 entries

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.)

  • Best score: 24
  • Best player score: 24
  • Position: #5 / 71
  • Number of attempts: 2
Getters & Setters: Java - 207 entries

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...

  • Best score: 89
  • Best player score: 92
  • Position: #7 / 58
  • Number of attempts: 4
Solve the Sokoban - 177 entries

A wink for all Vimgolfers that play Nethack too.

  • Best score: 25
  • Best player score: 30
  • Position: #20 / 74
  • Number of attempts: 2
Java Array2List - 233 entries

Convert an java array initializer into a list.

  • Best score: 67
  • Best player score: 77
  • Position: #10 / 87
  • Number of attempts: 1
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: #15 / 208
  • Number of attempts: 1
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: #4 / 406
  • Number of attempts: 3
CSV to JSON - 173 entries

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

  • Best score: 56
  • Best player score: 60
  • Position: #6 / 66
  • Number of attempts: 10
Assignment Alignment - 883 entries

line up the operators. Use spaces, not tabs.

  • Best score: 18
  • Best player score: 18
  • Position: #1 / 220
  • Number of attempts: 6
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: 12
  • Position: #83 / 515
  • Number of attempts: 4
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: #5 / 662
  • Number of attempts: 1
Round Round - 299 entries

Round Round

  • Best score: 19
  • Best player score: 23
  • Position: #23 / 87
  • Number of attempts: 7
82 bottles of beer on the wall - 312 entries

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

  • Best score: 106
  • Best player score: 109
  • Position: #13 / 145
  • Number of attempts: 4
Table Reshuffle - 410 entries

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

  • Best score: 22
  • Best player score: 24
  • Position: #33 / 138
  • Number of attempts: 5
Reverse and count - 473 entries

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

  • Best score: 18
  • Best player score: 23
  • Position: #48 / 176
  • Number of attempts: 4
Letters are numbers - 167 entries

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?

  • Best score: 20
  • Best player score: 26
  • Position: #17 / 76
  • Number of attempts: 2
Another Mixed-Up Haiku - 257 entries

VimGolf ... a perfect evening?

  • Best score: 21
  • Best player score: 21
  • Position: #1 / 89
  • Number of attempts: 3
Ruby 1.9 compat - 627 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: 14
  • Position: #9 / 233
  • Number of attempts: 4
Reverse Simple Deletion - 847 entries

You did the simple deletion, now reverse it.

  • Best score: 11
  • Best player score: 12
  • Position: #61 / 458
  • Number of attempts: 1
Increment, increment, increment.... - 684 entries

Vim likes macros

  • Best score: 10
  • Best player score: 12
  • Position: #112 / 406
  • Number of attempts: 1
Sorting paragraphs - 514 entries

Order the paragraphs correctly, per prefixed index

  • Best score: 18
  • Best player score: 21
  • Position: #20 / 161
  • Number of attempts: 6
Indentation - 534 entries

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

  • Best score: 20
  • Best player score: 23
  • Position: #17 / 177
  • Number of attempts: 5
Hatsuyume - 513 entries

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

  • Best score: 15
  • Best player score: 24
  • Position: #59 / 184
  • Number of attempts: 1
Turn this csv list into queries - 238 entries

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

  • Best score: 98
  • Best player score: 106
  • Position: #21 / 100
  • Number of attempts: 5
Dumb to smart - 97 entries

Turn dumb quote to smart vim's way.

  • Best score: 28
  • Best player score: 29
  • Position: #13 / 55
  • Number of attempts: 2
The Cake is a Lie - 1339 entries

Correct the capitalization of each word

  • Best score: 9
  • Best player score: 9
  • Position: #28 / 525
  • Number of attempts: 2
Fix the Haiku - 293 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: 30
  • Position: #13 / 112
  • Number of attempts: 4
Context insensitive completion 0 - 566 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: 6
  • Best player score: 7
  • Position: #28 / 244
  • Number of attempts: 2
Remove Accent off the Letter - 126 entries

Remove all the accent from extremely accented statements.

  • Best score: 37
  • Best player score: 66
  • Position: #31 / 51
  • Number of attempts: 4
Compile C - 420 entries

You might have to get clever to do this one.

  • Best score: 19
  • Best player score: 22
  • Position: #81 / 140
  • Number of attempts: 1
Context Insensitive completion 1 - 494 entries

Finish writing this simple Python HTTP server.

  • Best score: 18
  • Best player score: 18
  • Position: #45 / 243
  • Number of attempts: 1
Almost encrypted - 204 entries

Convert the first paragraph to be even less readable.

  • Best score: 5
  • Best player score: 5
  • Position: #18 / 146
  • Number of attempts: 1
Make Fancy Header - 1046 entries

Make the header text stand out with surrounding asterisks

  • Best score: 15
  • Best player score: 16
  • Position: #25 / 343
  • Number of attempts: 3
Linear congruential generator - 137 entries

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

  • Best score: 28
  • Best player score: 30
  • Position: #8 / 52
  • Number of attempts: 4
Reformat some Python - 604 entries

Fix some very bizarrely laid-out code.

  • Best score: 34
  • Best player score: 34
  • Position: #6 / 235
  • Number of attempts: 9
Reformat a C golf submission - 589 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: 27
  • Position: #41 / 207
  • Number of attempts: 4
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: 18
  • Position: #175 / 263
  • Number of attempts: 2
PEP8 Python Wrapping Comments and Code - 207 entries

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

  • Best score: 21
  • Best player score: 26
  • Position: #16 / 66
  • Number of attempts: 3
Reformat most common surnames - 698 entries

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

  • Best score: 23
  • Best player score: 25
  • Position: #39 / 208
  • Number of attempts: 7
Remember FizzBuzz? - 713 entries

Output FizzBuzz to 100. Start with nothing.

  • Best score: 39
  • Best player score: 50
  • Position: #46 / 188
  • Number of attempts: 7
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: #59 / 228
  • Number of attempts: 2
Change the content of a string - 1567 entries

This docstring is a complete lie. Fix it.

  • Best score: 22
  • Best player score: 22
  • Position: #21 / 585
  • Number of attempts: 6
Deleting folded text - 350 entries

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.

  • Best score: 17
  • Best player score: 19
  • Position: #23 / 116
  • Number of attempts: 4
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: #38 / 559
  • Number of attempts: 1
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: 30
  • Position: #2 / 181
  • Number of attempts: 6
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: 20
  • Position: #9 / 409
  • Number of attempts: 4
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: 37
  • Position: #52 / 312
  • Number of attempts: 6
Whitespace, empty lines and tabs - 3614 entries

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

  • Best score: 16
  • Best player score: 22
  • Position: #250 / 780
  • Number of attempts: 1
Flodder-challenge - 1245 entries

Replace the text the most efficient and win!

  • Best score: 27
  • Best player score: 28
  • Position: #42 / 333
  • Number of attempts: 7
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: #5 / 3681
  • Number of attempts: 5

Contributed Challenges

Overall Vimgolf Rank - 216 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.

Wei Dai
Twitter:

entered into 84 challenges

contributed 1 challenges