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

Refactor to Helpers - 45 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
  • Number of attempts: 2
Write Setters and Getters for PHP - 86 entries

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

  • Best score: 102
  • Best player score: 209
  • Number of attempts: 1
XML to JSON - 41 entries

Convert this xml file into json.

  • Best score: 75
  • Best player score: 185
  • Number of attempts: 1
Create Leading Zeros - 192 entries

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

  • Best score: 23
  • Best player score: 127
  • Number of attempts: 1
82 bottles of beer on the wall - 243 entries

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

  • Best score: 107
  • Best player score: 126
  • Number of attempts: 1
Shuffle puzzle - 289 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
  • Number of attempts: 1
Simple, Practical, and Common - 24823 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
  • Number of attempts: 1
Two become one - 675 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
  • Number of attempts: 7
Draw the Go board - 109 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
  • Number of attempts: 1
Line Zipper - 396 entries

Zip/pair related lines.

  • Best score: 12
  • Best player score: 22
  • Number of attempts: 1
The meaning - 498 entries

Numbers are fun!

  • Best score: 5
  • Best player score: 5
  • Number of attempts: 1
Python Hello World! Reformatting - 832 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
  • Number of attempts: 1
Numbering a List - 1727 entries

Pretty simple, number the list.

  • Best score: 13
  • Best player score: 21
  • Number of attempts: 2
Replacing some words - 400 entries

How fast could it be?

  • Best score: 17
  • Best player score: 17
  • Number of attempts: 7
NBCU Weekly Challenge - Test - 215 entries

Just testing.

  • Best score: 18
  • Best player score: 20
  • Number of attempts: 1
Hanging Indent for Footnotes - 58 entries

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

  • Best score: 17
  • Best player score: 26
  • Number of attempts: 1
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: 45
  • Number of attempts: 4
Return the cow - 71 entries

This cow is too verbose. Give it a lesson.

  • Best score: 52
  • Best player score: 131
  • Number of attempts: 1
Where should I put the Newline? - 796 entries

Help me put the newline.

  • Best score: 7
  • Best player score: 8
  • Number of attempts: 3
quotes inside quotes - 2770 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: 32
  • Number of attempts: 1
Remove noise from HTTP log - 603 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
  • Number of attempts: 1
Reconstruct the Sentence - 1024 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
  • Number of attempts: 1
Hole-in-one - 935 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
  • Number of attempts: 1
Make it more readable - 1755 entries

Insert blank lines to make it more organized and readable

  • Best score: 13
  • Best player score: 17
  • Number of attempts: 1
SFD-ROC: vimvimvim - 1285 entries

Oh no, this line is longer than 80 chars... put each 'vim' on a new line.

  • Best score: 8
  • Best player score: 14
  • Number of attempts: 1
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
Vice versa - 5903 entries

Little role switching.

  • Best score: 12
  • Best player score: 16
  • Number of attempts: 1
Swap assigned value - 496 entries

Simple problem but looking for interesting solutions.

  • Best score: 10
  • Best player score: 11
  • Number of attempts: 1
switch variable - 4301 entries

how fast can you switch two variable ?

  • Best score: 11
  • Best player score: 11
  • Number of attempts: 3
Compile C - 278 entries

You might have to get clever to do this one.

  • Best score: 19
  • Best player score: 23
  • Number of attempts: 1
Change the content of a string - 1234 entries

This docstring is a complete lie. Fix it.

  • Best score: 22
  • Best player score: 23
  • Number of attempts: 2
Top X - 177 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
  • Number of attempts: 3
paste indent correction - JS - 75 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
  • Number of attempts: 2
Ugly spreadsheet copy/paste to CSV - 725 entries

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

  • Best score: 19
  • Best player score: 55
  • Number of attempts: 1
maximun and minimun - 44 entries

Find the maximum and minimum of the rows.

  • Best score: 51
  • Best player score: 133
  • Number of attempts: 2
Under the cupola - 37 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
  • Number of attempts: 1
Let's play some Ivmgolf - 909 entries

Oops, I spelled that wrong.

  • Best score: 7
  • Best player score: 14
  • 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: 23
  • Number of attempts: 2
Letter case trickery - 1433 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
  • Number of attempts: 1
A simple change - 359 entries

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

  • Best score: 12
  • Best player score: 14
  • Number of attempts: 3
Braces or Brackets? - 626 entries

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

  • Best score: 34
  • Best player score: 40
  • Number of attempts: 1
Just the middle - 9164 entries

Delete the instructions at the top and bottom.

  • Best score: 7
  • Best player score: 8
  • Number of attempts: 1
A HAPPY NEW YEAR 2014 ! - 9475 entries

A HAPPY NEW YEAR 2014 !

  • Best score: 11
  • Best player score: 13
  • Number of attempts: 3
The Cake is a Lie - 1119 entries

Correct the capitalization of each word

  • Best score: 9
  • Best player score: 28
  • Number of attempts: 1
Words in parens - 11002 entries

We should all ace this, right?

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

Assign list elements to matrix

  • Best score: 30
  • Best player score: 49
  • Number of attempts: 1
-a-b-c- - 2569 entries

Put hyphens everywhere.

  • Best score: 13
  • Best player score: 15
  • 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: 1
Across-Down Flip - 42 entries

Do this instead of the Sunday crossword.

  • Best score: 24
  • Best player score: 67
  • Number of attempts: 1
Shebangs for all - 1588 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
  • Number of attempts: 1
NATO phonetic alphabet - 394 entries

Transform the series of words into a list.

  • Best score: 19
  • Best player score: 22
  • Number of attempts: 1
It's a factor - 75 entries

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

  • Best score: 25
  • Best player score: 124
  • Number of attempts: 1
Append semicolon after expressions - 852 entries

Some lines need the semicolon, some don't.

  • Best score: 11
  • Best player score: 12
  • Number of attempts: 3
Count both ways - 864 entries

Right AND down.

  • Best score: 13
  • Best player score: 16
  • Number of attempts: 1
Do you demand a shrubbery? - 1013 entries

Use :redir and crush the emacsgolfers.

  • Best score: 15
  • Best player score: 22
  • Number of attempts: 2
Change name of a variable - 146 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
  • Number of attempts: 1
Don't know what this is - 1730 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
  • Number of attempts: 2
Search and Replace 0 - 4091 entries

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

  • Best score: 12
  • Best player score: 16
  • Number of attempts: 1
replacing each line of a block selection - 2508 entries

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

  • Best score: 18
  • Best player score: 28
  • Number of attempts: 1
Extract argument from function - 2000 entries

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

  • Best score: 13
  • Best player score: 14
  • Number of attempts: 2
Simple text editing with Vim - 10385 entries

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

  • Best score: 13
  • Best player score: 16
  • Number of attempts: 2
Indentation - 416 entries

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

  • Best score: 21
  • Best player score: 27
  • Number of attempts: 2
Vertical Limit - 2106 entries

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

  • Best score: 21
  • Best player score: 28
  • Number of attempts: 1
Hatsuyume - 365 entries

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

  • Best score: 16
  • Best player score: 26
  • Number of attempts: 5
JS notation to Immutable.js notation - 143 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: 35
  • Best player score: 43
  • Number of attempts: 3
Remove semicolons after expressions - 451 entries

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

  • Best score: 6
  • Best player score: 9
  • Number of attempts: 1
The Universal Declaration of Human Rights, Article 1 - 128 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
  • Number of attempts: 1
Make Fancy Header - 909 entries

Make the header text stand out with surrounding asterisks

  • Best score: 16
  • Best player score: 30
  • Number of attempts: 1
Cartesian product - 201 entries

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

  • Best score: 24
  • Best player score: 35
  • Number of attempts: 1
Refactor static member invocation - 180 entries

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

  • Best score: 28
  • Best player score: 54
  • Number of attempts: 1
Saving the hashes(#) - 1740 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
  • Number of attempts: 1
Vim tetris - 338 entries

Vim can play tetris too!

  • Best score: 21
  • Best player score: 32
  • Number of attempts: 2
attr_aligner - 2992 entries

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

  • Best score: 19
  • Best player score: 33
  • Number of attempts: 3
NBCU Weekly Challenge - #0 - 118 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
  • Number of attempts: 1
Before there was Farmville... - 91 entries

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

  • Best score: 156
  • Best player score: 257
  • Number of attempts: 2
Comparing scores - 68 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
  • Number of attempts: 5
Going underground.... - 283 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
  • Number of attempts: 1
Reformat/Refactor a Golfer Class - 5482 entries

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

  • Best score: 32
  • Best player score: 35
  • Number of attempts: 4
Exchanging Quotes - 759 entries

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

  • Best score: 30
  • Best player score: 37
  • Number of attempts: 1
Mess in revision history - 964 entries

Help Joe clean up what Steve has cobbled.

  • Best score: 17
  • Best player score: 38
  • Number of attempts: 2
Piphilology - 114 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: 29
  • Best player score: 38
  • Number of attempts: 3
vim1001 - 235 entries

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

  • Best score: 17
  • Best player score: 27
  • 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: 39
  • Number of attempts: 1
lamb had a little Mary - 485 entries

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

  • Best score: 16
  • Best player score: 40
  • Number of attempts: 2
Lisp Condense - 378 entries

Reduce 4 cons selection operations down to one function call.

  • Best score: 13
  • Best player score: 14
  • 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: 2
Carriage return - 41 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
  • Number of attempts: 1
Neither Fizz nor Buzz - 191 entries

Not your regular increment macro! The gaps are tricky.

  • Best score: 13
  • Best player score: 43
  • Number of attempts: 2
The holy-grail may help - 301 entries

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

  • Best score: 16
  • Best player score: 25
  • Number of attempts: 2
120 Degrees - 351 entries

Rotate that triangle.

  • Best score: 14
  • Best player score: 20
  • Number of attempts: 3
Suffix sort - 166 entries

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

  • Best score: 19
  • Best player score: 30
  • Number of attempts: 3
Minimalist Limerick - 459 entries

Reproduce this lovely poem.

  • Best score: 31
  • Best player score: 56
  • Number of attempts: 1
Extract text from xml - 101 entries

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

  • Best score: 28
  • Best player score: 63
  • Number of attempts: 1
Chucking wood - 75 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
  • Number of attempts: 4
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
V to the i - 3901 entries

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

  • Best score: 7
  • Best player score: 9
  • Number of attempts: 2
Manual SQL - 93 entries

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

  • Best score: 49
  • Best player score: 74
  • Number of attempts: 1
PHP Array Syntax -> MailChimp Merge Syntax - 421 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
  • Number of attempts: 1
Five Pillars - 43 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
  • 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: 43
  • Number of attempts: 2
HTML formatting: vertical alignment for readability - 59 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: 33
  • Best player score: 93
  • Number of attempts: 1
Circle in a square - 125 entries

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

  • Best score: 23
  • Best player score: 101
  • Number of attempts: 1
Recursive Cowsay - 49 entries

Convert 'cowsay' statement to recursive output

  • Best score: 33
  • Best player score: 78
  • Number of attempts: 2
Create bison tokens - 32 entries

Create tokens for bison out of a known list of words

  • Best score: 85
  • Best player score: 103
  • Number of attempts: 2
RobertT
Twitter:

entered into 105 challenges

contributed 0 challenges