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

Simple, Practical, and Common - 33616 entries

Simple things we do all the time should be able to be done with very few keystrokes, but sometimes I find something I need to do makes me go, "There MUST be a better way." This challenge is just a simple movement and entering text at a certain place.

  • Best score: 22
  • Best player score: 24
  • Position: #2852 / 7420
  • Number of attempts: 1
vim = 22 / 7 - 475 entries

pi square vim

  • Best score: 20
  • Best player score: 32
  • Position: #94 / 135
  • Number of attempts: 1
V to the i - 4802 entries

Input is 99 V's. Output is 100 i's.

  • Best score: 7
  • Best player score: 9
  • Position: #1500 / 1893
  • Number of attempts: 2
Extract argument from function - 2357 entries

The aim is to see if you can do some refactoring very fast.

  • Best score: 13
  • Best player score: 14
  • Position: #277 / 753
  • Number of attempts: 2
Search and Replace 0 - 4989 entries

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

  • Best score: 12
  • Best player score: 16
  • Position: #1161 / 1624
  • Number of attempts: 1
Across-Down Flip - 68 entries

Do this instead of the Sunday crossword.

  • Best score: 23
  • Best player score: 67
  • Position: #25 / 26
  • Number of attempts: 1
Just the middle - 11454 entries

Delete the instructions at the top and bottom.

  • Best score: 7
  • Best player score: 8
  • Position: #2083 / 4197
  • Number of attempts: 1
Python Hello World! Reformatting - 994 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: 51
  • Position: #354 / 380
  • Number of attempts: 1
Return the cow - 75 entries

This cow is too verbose. Give it a lesson.

  • Best score: 52
  • Best player score: 131
  • Position: #27 / 30
  • Number of attempts: 1
Create Leading Zeros - 241 entries

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

  • Best score: 23
  • Best player score: 127
  • Position: #82 / 82
  • Number of attempts: 1
JS notation to Immutable.js notation - 186 entries

Now Immutable.js made its way into many frontends. This challenge consists of a typical refactoring that many of us are facing now.

  • Best score: 34
  • Best player score: 43
  • Position: #46 / 63
  • Number of attempts: 3
Vice versa - 7907 entries

Little role switching.

  • Best score: 12
  • Best player score: 16
  • Position: #1200 / 2128
  • Number of attempts: 1
Create bison tokens - 47 entries

Create tokens for bison out of a known list of words

  • Best score: 85
  • Best player score: 103
  • Position: #13 / 18
  • Number of attempts: 2
Manual SQL - 160 entries

Change select and insert queries to simulate inserting a new record.

  • Best score: 48
  • Best player score: 74
  • Position: #38 / 50
  • Number of attempts: 1
Swap assigned value - 647 entries

Simple problem but looking for interesting solutions.

  • Best score: 10
  • Best player score: 11
  • Position: #144 / 254
  • Number of attempts: 1
Cartesian product - 255 entries

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

  • Best score: 24
  • Best player score: 35
  • Position: #60 / 95
  • Number of attempts: 1
vim1001 - 307 entries

change number 1001 into a "vim1001 sequence". (My first challenge, hope it is not too bad... )

  • Best score: 17
  • Best player score: 27
  • Position: #91 / 110
  • Number of attempts: 1
-a-b-c- - 3213 entries

Put hyphens everywhere.

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

Right AND down.

  • Best score: 13
  • Best player score: 16
  • Position: #137 / 354
  • Number of attempts: 1
Suffix sort - 270 entries

Sort from the end of the line, as if the letters in each line were reversed.

  • Best score: 19
  • Best player score: 30
  • Position: #57 / 67
  • Number of attempts: 3
NBCU Weekly Challenge - Test - 253 entries

Just testing.

  • Best score: 18
  • Best player score: 20
  • Position: #82 / 116
  • Number of attempts: 1
Change name of a variable - 179 entries

Replace the name of the $variable with the fastest move possible. The challenge is having a command that allow you to easily change the variable name even if its indented.

  • Best score: 9
  • Best player score: 9
  • Position: #26 / 137
  • Number of attempts: 1
Lisp Condense - 460 entries

Reduce 4 cons selection operations down to one function call.

  • Best score: 13
  • Best player score: 14
  • Position: #63 / 158
  • Number of attempts: 1
120 Degrees - 493 entries

Rotate that triangle.

  • Best score: 14
  • Best player score: 20
  • Position: #79 / 145
  • Number of attempts: 3
NBCU Weekly Challenge - #0 - 139 entries

One of our favorites lines here at NBCU! p.s. The first version of #0 was deleted due to me copy/pasting a HTML entity. Congrats to the one who figured that out, you are a true ninja warrior!

  • Best score: 30
  • Best player score: 33
  • Position: #33 / 58
  • Number of attempts: 1
Refactor static member invocation - 199 entries

Someone used a static method. Refactor the method into a static import while fixing the assertion.

  • Best score: 28
  • Best player score: 54
  • Position: #61 / 64
  • Number of attempts: 1
Comparing scores - 112 entries

If Alice and Bob both did the challenge, put their entries together in the top paragraph, so we can compare their scores more easily.

  • Best score: 18
  • Best player score: 33
  • Position: #23 / 35
  • Number of attempts: 5
Neither Fizz nor Buzz - 253 entries

Not your regular increment macro! The gaps are tricky.

  • Best score: 13
  • Best player score: 43
  • Position: #100 / 103
  • Number of attempts: 2
Do you demand a shrubbery? - 1158 entries

Use :redir and crush the emacsgolfers.

  • Best score: 15
  • Best player score: 22
  • Position: #174 / 300
  • Number of attempts: 2
Don't know what this is - 2022 entries

Replace contents of brackets with matching number of spaces. Don't ask what the format's supposed to be.

  • Best score: 11
  • Best player score: 17
  • Position: #542 / 585
  • Number of attempts: 2
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: 33
  • Position: #123 / 208
  • Number of attempts: 7
Where should I put the Newline? - 881 entries

Help me put the newline.

  • Best score: 7
  • Best player score: 8
  • Position: #234 / 437
  • Number of attempts: 3
Vim tetris - 353 entries

Vim can play tetris too!

  • Best score: 21
  • Best player score: 32
  • Position: #84 / 102
  • Number of attempts: 2
Five Pillars - 63 entries

Arrange all words in a table with 5 columns. The minimal space between words in columns is 2 spaces. Columns do have varying width.

  • Best score: 41
  • Best player score: 88
  • Position: #24 / 24
  • Number of attempts: 1
Piphilology - 144 entries

Piphilology comprises the creation and use of mnemonic techniques to remember a span of digits of the mathematical constant π. http://en.wikipedia.org/wiki/Piphilology

  • Best score: 28
  • Best player score: 38
  • Position: #28 / 52
  • Number of attempts: 3
Mess in revision history - 1184 entries

Help Joe clean up what Steve has cobbled.

  • Best score: 17
  • Best player score: 38
  • Position: #223 / 250
  • Number of attempts: 2
Shuffle puzzle - 346 entries

Sort the lines in each indent group, and sort the groups. That's the pattern. Or just move lines around manually to get a better score.

  • Best score: 13
  • Best player score: 26
  • Position: #102 / 104
  • Number of attempts: 1
Carriage return - 43 entries

I have some raw data from terminal output which uses carriege return for formatting. Carriage return sets the pointer to the first character on the line, and subsequent characters will overwrite what was there before. The challange is to simulate the terminal behaviour in vim. I'm kind of unsure if I should have skipped lines 9 and 15, since there might be some interesting solutions which are not that generic. Happy Golfing!

  • Best score: 22
  • Best player score: 45
  • Position: #20 / 21
  • Number of attempts: 1
HTML formatting: vertical alignment for readability - 88 entries

We did this a VimGolf challenge at work and now that we have finished I want to see if you guys can come up with something even better than we could. Our best solution was 44 keystrokes.

  • Best score: 32
  • Best player score: 93
  • Position: #29 / 36
  • Number of attempts: 1
Write Setters and Getters for PHP - 88 entries

Just simple automation of writing Setters and Getters like Doctrine might use.

  • Best score: 102
  • Best player score: 209
  • Position: #32 / 33
  • Number of attempts: 1
Going underground.... - 356 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: 34
  • Position: #98 / 128
  • Number of attempts: 1
Split the words - 368 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: #81 / 111
  • Number of attempts: 2
A HAPPY NEW YEAR 2014 ! - 10663 entries

A HAPPY NEW YEAR 2014 !

  • Best score: 11
  • Best player score: 13
  • Position: #2525 / 3683
  • Number of attempts: 3
attr_aligner - 3520 entries

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

  • Best score: 19
  • Best player score: 33
  • Position: #503 / 702
  • Number of attempts: 3
Under the cupola - 57 entries

Taking some liberty about the name and plot of the Stephen King's famous novel (and TV series) to make this challenge. Are you able to recreate graphically the key phrase of the story? (I think is gonna be hard!)

  • Best score: 33
  • Best player score: 128
  • Position: #18 / 19
  • Number of attempts: 1
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: 45
  • Position: #39 / 41
  • Number of attempts: 4
Counting in binary - 526 entries

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

  • Best score: 16
  • Best player score: 43
  • Position: #88 / 117
  • Number of attempts: 2
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: 13
  • Position: #367 / 518
  • 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: #522 / 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: 26
  • Position: #21 / 30
  • Number of attempts: 1
Recursive Cowsay - 64 entries

Convert 'cowsay' statement to recursive output

  • Best score: 33
  • Best player score: 78
  • Position: #17 / 19
  • Number of attempts: 2
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: 27
  • Position: #37 / 71
  • 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: #60 / 78
  • Number of attempts: 1
Words in parens - 12935 entries

We should all ace this, right?

  • Best score: 13
  • Best player score: 17
  • Position: #2545 / 3963
  • Number of attempts: 2
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: 39
  • Position: #81 / 136
  • Number of attempts: 1
Assign list - 192 entries

Assign list elements to matrix

  • Best score: 30
  • Best player score: 49
  • Position: #37 / 61
  • Number of attempts: 1
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: 63
  • Position: #16 / 51
  • Number of attempts: 1
paste indent correction - JS - 112 entries

You copy some javascript code from a website and paste it into vim, it does not look good!

  • Best score: 16
  • Best player score: 45
  • Position: #58 / 59
  • 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: 17
  • Position: #99 / 304
  • Number of attempts: 1
It's a factor - 104 entries

Flaunt your macro prowess by factoring some numbers. Too hard? It takes less than 30 strokes, I promise.

  • Best score: 24
  • Best player score: 124
  • Position: #36 / 38
  • 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: 23
  • Position: #49 / 77
  • Number of attempts: 2
Minimalist Limerick - 520 entries

Reproduce this lovely poem.

  • Best score: 30
  • Best player score: 56
  • Position: #168 / 174
  • Number of attempts: 1
XML to JSON - 47 entries

Convert this xml file into json.

  • Best score: 75
  • Best player score: 185
  • Position: #13 / 20
  • Number of attempts: 1
Circle in a square - 152 entries

Probably looks more like "Egg in a rectangle" in most fonts, but it's actually 23x23.

  • Best score: 23
  • Best player score: 101
  • Position: #54 / 54
  • Number of attempts: 1
NATO phonetic alphabet - 529 entries

Transform the series of words into a list.

  • Best score: 19
  • Best player score: 22
  • Position: #115 / 196
  • Number of attempts: 1
A simple change - 461 entries

Just change the numbers in the most efficient way ...

  • Best score: 12
  • Best player score: 14
  • Position: #104 / 191
  • Number of attempts: 3
Extract text from xml - 127 entries

Extract text from xml file (ignoring commented out elements) and create a one line regex.

  • Best score: 28
  • Best player score: 63
  • Position: #41 / 46
  • Number of attempts: 1
lamb had a little Mary - 609 entries

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

  • Best score: 16
  • Best player score: 40
  • Position: #136 / 168
  • Number of attempts: 2
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: 14
  • Position: #343 / 446
  • Number of attempts: 1
Chucking wood - 129 entries

An exercise in compressing repetitive text. For this challenge, any entry that uses keys outside the main row (such as arrow keys, Home, End, Delete, etc.) will be removed. (Esc is OK, though you should be using C-[ anyway.)

  • Best score: 51
  • Best player score: 65
  • Position: #42 / 49
  • Number of attempts: 4
Stairs Indenting - 473 entries

Indent each line with <line number> whitespaces.

  • Best score: 12
  • Best player score: 14
  • Position: #108 / 197
  • Number of attempts: 1
maximun and minimun - 73 entries

Find the maximum and minimum of the rows.

  • Best score: 50
  • Best player score: 133
  • Position: #26 / 26
  • Number of attempts: 2
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: 31
  • Position: #405 / 480
  • Number of attempts: 1
Let's play some Ivmgolf - 1118 entries

Oops, I spelled that wrong.

  • Best score: 7
  • Best player score: 14
  • Position: #422 / 445
  • Number of attempts: 1
Vertical Limit - 2538 entries

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

  • Best score: 21
  • Best player score: 28
  • Position: #573 / 754
  • 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: 37
  • Position: #129 / 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: 28
  • Position: #597 / 777
  • Number of attempts: 1
Append semicolon after expressions - 1056 entries

Some lines need the semicolon, some don't.

  • Best score: 11
  • Best player score: 12
  • Position: #196 / 419
  • Number of attempts: 3
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: 17
  • Position: #211 / 273
  • Number of attempts: 1
Remove semicolons after expressions - 654 entries

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

  • Best score: 6
  • Best player score: 9
  • Position: #237 / 263
  • Number of attempts: 1
switch variable - 5071 entries

how fast can you switch two variable ?

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

Numbers are fun!

  • Best score: 5
  • Best player score: 5
  • Position: #187 / 363
  • Number of attempts: 1
Ugly spreadsheet copy/paste to CSV - 1009 entries

convert an ugly spreadsheet copy/paste into a CSV format.

  • Best score: 19
  • Best player score: 55
  • Position: #170 / 193
  • Number of attempts: 1
Replacing some words - 428 entries

How fast could it be?

  • Best score: 17
  • Best player score: 17
  • Position: #24 / 151
  • Number of attempts: 7
Make it more readable - 2005 entries

Insert blank lines to make it more organized and readable

  • Best score: 13
  • Best player score: 17
  • Position: #451 / 650
  • Number of attempts: 1
Line Zipper - 473 entries

Zip/pair related lines.

  • Best score: 12
  • Best player score: 22
  • Position: #207 / 215
  • Number of attempts: 1
PHP Array Syntax -> MailChimp Merge Syntax - 545 entries

I recently needed to send an e-mail to our marketing department listing allowed merge tags for our MailChimp campaigns. The allowed merge tags were determined from a PHP array in one of our PHP classes. I transformed the PHP class to MailChimp's syntax and sent the e-mail. It was, however, a long, laborious process. I'm still fairly new to Vim and would love to see how an expert Vim user would tackle one of my own, real-world problems. Thanks and have fun!

  • Best score: 23
  • Best player score: 32
  • Position: #78 / 150
  • Number of attempts: 1
Refactor to Helpers - 50 entries

This Rails partial is almost all template escapes. Put it into a helper, and refactor each case to methods so we can build out the controls for each. (I've converted to tabs - fighting with Vimgolf's default config shouldn't be part of the challenge.)

  • Best score: 147
  • Best player score: 242
  • Position: #10 / 25
  • Number of attempts: 2
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: 257
  • Position: #43 / 49
  • Number of attempts: 2
Numbering a List - 1931 entries

Pretty simple, number the list.

  • Best score: 13
  • Best player score: 21
  • Position: #388 / 652
  • Number of attempts: 2
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: 29
  • Position: #58 / 71
  • Number of attempts: 1
The holy-grail may help - 366 entries

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

  • Best score: 16
  • Best player score: 25
  • Position: #199 / 209
  • Number of attempts: 2
Shebangs for all - 1999 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: 16
  • Position: #309 / 516
  • Number of attempts: 1
82 bottles of beer on the wall - 313 entries

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

  • Best score: 106
  • Best player score: 126
  • Position: #63 / 146
  • Number of attempts: 1
Indentation - 542 entries

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

  • Best score: 20
  • Best player score: 27
  • Position: #82 / 178
  • Number of attempts: 2
Hatsuyume - 532 entries

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

  • Best score: 15
  • Best player score: 26
  • Position: #100 / 186
  • Number of attempts: 5
The Cake is a Lie - 1346 entries

Correct the capitalization of each word

  • Best score: 9
  • Best player score: 28
  • Position: #524 / 527
  • Number of attempts: 1
Compile C - 430 entries

You might have to get clever to do this one.

  • Best score: 19
  • Best player score: 23
  • Position: #100 / 141
  • Number of attempts: 1
Make Fancy Header - 1052 entries

Make the header text stand out with surrounding asterisks

  • Best score: 15
  • Best player score: 30
  • Position: #330 / 344
  • Number of attempts: 1
Get rid of html tags - 398 entries

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

  • Best score: 12
  • Best player score: 17
  • Position: #102 / 230
  • Number of attempts: 1
Change the content of a string - 1580 entries

This docstring is a complete lie. Fix it.

  • Best score: 22
  • Best player score: 23
  • Position: #276 / 588
  • Number of attempts: 2
Reconstruct the Sentence - 1507 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: 25
  • Position: #335 / 412
  • Number of attempts: 1
Braces or Brackets? - 1015 entries

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

  • Best score: 34
  • Best player score: 40
  • Position: #93 / 315
  • Number of attempts: 1
Simple text editing with Vim - 12811 entries

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

  • Best score: 13
  • Best player score: 16
  • Position: #2183 / 3694
  • Number of attempts: 2
Reformat/Refactor a Golfer Class - 6982 entries

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

  • Best score: 28
  • Best player score: 35
  • Position: #352 / 1706
  • Number of attempts: 4
RobertT
Twitter:

entered into 105 challenges

contributed 0 challenges