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

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: 123
  • Number of attempts: 4
Gray area - 645 entries

It's a golf metaphor or something.

  • Best score: 11
  • Best player score: 13
  • Number of attempts: 4
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: 24
  • 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: 31
  • Number of attempts: 2
120 Degrees - 366 entries

Rotate that triangle.

  • Best score: 14
  • Best player score: 26
  • Number of attempts: 1
Basic renumbering - 4690 entries

Renumbering Basic.

  • Best score: 11
  • Best player score: 18
  • Number of attempts: 3
vim = 22 / 7 - 398 entries

pi square vim

  • Best score: 20
  • Best player score: 34
  • Number of attempts: 2
underscore_to_camelCase - 137 entries

Pointy haired boss decided we need to switch to camelCase. Let's get this over with.

  • Best score: 14
  • Best player score: 15
  • Number of attempts: 1
Create bison tokens - 32 entries

Create tokens for bison out of a known list of words

  • Best score: 85
  • Best player score: 89
  • Number of attempts: 1
Wget failed to download redirections - 158 entries

Output of a wget session, where 302 where not properly handled due to certificate problems, has been saved to a file. Keep the correct URLs to start again downloading.

  • Best score: 15
  • Best player score: 15
  • Number of attempts: 9
-a-b-c- - 2637 entries

Put hyphens everywhere.

  • Best score: 13
  • Best player score: 15
  • Number of attempts: 2
NBCU Weekly Challenge - Test - 215 entries

Just testing.

  • Best score: 18
  • Best player score: 18
  • Number of attempts: 3
Shift down - 179 entries

Number words are back.

  • Best score: 19
  • Best player score: 30
  • Number of attempts: 3
Collect List - 3553 entries

Convert to comma separated list.

  • Best score: 12
  • Best player score: 14
  • Number of attempts: 3
Space out the alphabet - 1382 entries

Put 3 spaces between adjacent letters.

  • Best score: 15
  • Best player score: 18
  • Number of attempts: 5
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: 14
  • Number of attempts: 6
Don't know what this is - 1775 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: 14
  • Number of attempts: 1
Condensed Cases - 695 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: 1
Words in parens - 11183 entries

We should all ace this, right?

  • Best score: 14
  • Best player score: 14
  • Number of attempts: 4
V to the i - 3977 entries

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

  • Best score: 7
  • Best player score: 9
  • Number of attempts: 2
comments galore - 908 entries

Basic comment reformatting

  • Best score: 10
  • Best player score: 11
  • Number of attempts: 1
Fun With The Diagonal - 85 entries

change the lowercase characters on the main diagonal to uppercase

  • Best score: 11
  • Best player score: 11
  • Number of attempts: 1
Replace and keep the case - 347 entries

Replace all instance of plugin and Plugin to device and Device.

  • Best score: 26
  • Best player score: 29
  • Number of attempts: 4
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
Extended Customer 2 - 44 entries

Format the chars

  • Best score: 47
  • Best player score: 71
  • Number of attempts: 1
Assign numbers to fields - 85 entries

You are given a list of space-separated strings. Add an increasing numeric prefix to each one.

  • Best score: 19
  • Best player score: 19
  • Number of attempts: 2
Entries sort - 71 entries

It cames to my mind a weird idea : sorting parts of my .vimrc. Take few minutes to sort out this, it's easy !

  • Best score: 14
  • Best player score: 18
  • Number of attempts: 2
Lookahead and Lookbehind - 62 entries

Look everywhere

  • Best score: 16
  • Best player score: 20
  • Number of attempts: 5
remove all lines in first part - 149 entries

From the second part, remove all lines in the first part. It can be useful when you have done something from a long list, you want to know what is not done yet!

  • Best score: 13
  • Best player score: 20
  • 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: 22
  • Number of attempts: 4
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: 20
  • Number of attempts: 1
Count both ways - 878 entries

Right AND down.

  • Best score: 13
  • Best player score: 16
  • Number of attempts: 3
Where should I put the Newline? - 798 entries

Help me put the newline.

  • Best score: 7
  • Best player score: 8
  • Number of attempts: 2
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: 32
  • Number of attempts: 2
FoodCritic023: Prefer conditional attributes - 161 entries

FoodCritic (www.foodcritic.io) is a lint tool for your Chef (learn.chef.io) cookbooks. FC023 indicates that you should prefer Chef guards over Ruby conditions. This challenge expects you to be able to fix this issue in a sample cookbook, given the FoodCritic output: ================================================================ FC023: Prefer conditional attributes: cookbooks/foo/recipes/default.rb:25 ================================================================ See http://www.foodcritic.io/#FC023 for more details about the changes being made.

  • Best score: 25
  • Best player score: 30
  • Number of attempts: 5
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: 17
  • Number of attempts: 3
A HAPPY NEW YEAR 2014 ! - 9608 entries

A HAPPY NEW YEAR 2014 !

  • Best score: 11
  • Best player score: 11
  • Number of attempts: 4
Just the middle - 9428 entries

Delete the instructions at the top and bottom.

  • Best score: 7
  • Best player score: 8
  • Number of attempts: 7
That hyphen - 2205 entries

"vim vi improved"

  • Best score: 9
  • Best player score: 11
  • Number of attempts: 2
Logging with key - 275 entries

Sometimes it is better to log with meaningful key

  • Best score: 21
  • Best player score: 24
  • Number of attempts: 6
Happy TvvO - 354 entries

Don’t forget the past, learn from it. Happy New Year.

  • Best score: 12
  • Best player score: 12
  • Number of attempts: 3
Winning streak - 105 entries

Make the number on each line equal the consecutive L's or W's.

  • Best score: 21
  • Best player score: 26
  • Number of attempts: 2
range(10) digit rotation - 32 entries

This is a data generator challenge or some kind of gift..

  • Best score: 18
  • Best player score: 18
  • Number of attempts: 3
Permutations N=4 - 55 entries

Could use backtracking or other algorithm to generate sorted numbers. Second chance !

  • Best score: 25
  • Best player score: 37
  • Number of attempts: 4
VimGolfNight - 458 entries

Based on "The name of the game".

  • Best score: 12
  • Best player score: 12
  • Number of attempts: 2
Mirror Symmetry - 701 entries

Add backslashes.

  • Best score: 7
  • Best player score: 12
  • Number of attempts: 1
I forgot quotes - 12173 entries

Oops.

  • Best score: 10
  • Best player score: 10
  • Number of attempts: 4
Roman numerals - 57 entries

Use the substitutions on top to convert unary to Roman numerals.

  • Best score: 17
  • Best player score: 23
  • Number of attempts: 2
Swap values - 3628 entries

Well, swap the values...

  • Best score: 11
  • Best player score: 13
  • Number of attempts: 6
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: 24
  • Number of attempts: 1
quotes inside quotes - 2807 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
Add to end of each line... kinda - 264 entries

Visual-block mode can be used to add something to the end of each line, even if they are of differing lengths. However, what if it's not quite at the end?

  • Best score: 12
  • Best player score: 12
  • Number of attempts: 1
Assign list - 145 entries

Assign list elements to matrix

  • Best score: 30
  • Best player score: 46
  • Number of attempts: 4
Inner hyphens - 111 entries

Yet another hyphen challenge. Adding 5 hyphens to a file shouldn't be too hard.

  • Best score: 11
  • Best player score: 12
  • Number of attempts: 1
Hole-in-one - 936 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: 21
  • Number of attempts: 1
Sorting a glossary - 101 entries

Sort a glossary. Glossary head contains a header phrase ending with ':' and glossary body has multi line text indented with a tab.

  • Best score: 6
  • Best player score: 6
  • Number of attempts: 1
Simple, Practical, and Common - 25753 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: 22
  • Number of attempts: 6
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: 32
  • Number of attempts: 3
Letter case trickery - 1448 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: 12
  • Number of attempts: 3
Alsa configuration - 471 entries

I'm tweaking my ~/.asoundrc file!

  • Best score: 22
  • Best player score: 22
  • Number of attempts: 8
Vice versa - 6071 entries

Little role switching.

  • Best score: 12
  • Best player score: 14
  • Number of attempts: 2
Separating firstname & lastname - 102 entries

Seperate named with equal tabs.

  • Best score: 19
  • Best player score: 23
  • 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: 25
  • Number of attempts: 4
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: 72
  • Number of attempts: 3
learn vim in short time - 186 entries

so happy to learn vim.because vim is awesome

  • Best score: 8
  • Best player score: 8
  • Number of attempts: 1
Test everything! - 111 entries

... and build the desired input data structure. Transform a list of values into a non-trivial format.

  • Best score: 22
  • Best player score: 25
  • Number of attempts: 7
Free hyphen! - 115 entries

Just like "Inner hyphens", but I'm giving you a free hyphen to play with. Will your solution be any different?

  • Best score: 9
  • Best player score: 11
  • Number of attempts: 2
Vim's not included features - 157 entries

Filter not included (-) features in a hypothetical installation of vim.

  • Best score: 23
  • Best player score: 25
  • Number of attempts: 4
JSON string rotation - 38 entries

Right value strings are misplaced. Just rotate them! I'm too kind with you guys and didn't included "strings with \" in it"!

  • Best score: 19
  • Best player score: 26
  • Number of attempts: 5
paste indent correction - JS - 76 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: 18
  • Number of attempts: 3
Make HTML List - 910 entries

Turn the comma separated list into an unordered html list.

  • Best score: 33
  • Best player score: 39
  • Number of attempts: 2
Extract argument from function - 2019 entries

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

  • Best score: 13
  • Best player score: 14
  • Number of attempts: 3
Sorting database text output - 188 entries

Sometimes it is nice to be able to quickly take column-formatted text output from the SQL command line and turn it into a list of useful data. In this case we want a unique, sorted list of the values from the second column combined into one comma-separated list. What is the fewest strokes you can do this in?

  • Best score: 24
  • Best player score: 26
  • Number of attempts: 5
Replace Parameter with Explicit Methods - 61 entries

Implementing the methods of a Java Interface

  • Best score: 33
  • Best player score: 37
  • Number of attempts: 5
Delete unwanted lines - 336 entries

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

  • Best score: 9
  • Best player score: 9
  • Number of attempts: 2
Scrambled numbers - 730 entries

Four is NOT 1. One is 1.

  • Best score: 18
  • Best player score: 26
  • Number of attempts: 4
Mess in revision history - 985 entries

Help Joe clean up what Steve has cobbled.

  • Best score: 17
  • Best player score: 27
  • 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: 29
  • Number of attempts: 3
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: 29
  • Number of attempts: 7
increment by column in XML - 140 entries

modify an arbitrary "column" in an xml table by incrementing a an arbitrary placeholder string

  • Best score: 19
  • Best player score: 20
  • Number of attempts: 6
Vim tetris - 338 entries

Vim can play tetris too!

  • Best score: 21
  • Best player score: 31
  • Number of attempts: 1
Do you demand a shrubbery? - 1016 entries

Use :redir and crush the emacsgolfers.

  • Best score: 15
  • Best player score: 32
  • Number of attempts: 1
Lisp Condense - 387 entries

Reduce 4 cons selection operations down to one function call.

  • Best score: 13
  • Best player score: 15
  • 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: 36
  • Number of attempts: 2
Winding path - 91 entries

It's a maze, but the bad paths have been blocked off. Mark the correct path.

  • Best score: 27
  • Best player score: 44
  • Number of attempts: 3
Piphilology - 122 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: 2
lipsum lines - 239 entries

Convert a quoted block of text into strings in a list.

  • Best score: 28
  • Best player score: 31
  • Number of attempts: 5
No naked if allowed! - 19 entries

House style forbids naked condition statements, comments should start with a space character and be on their own line. Good luck!

  • Best score: 43
  • Best player score: 56
  • 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: 64
  • Number of attempts: 2
Mute the second method of this script - 412 entries

prepend a # infront of every line of the second method

  • Best score: 9
  • Best player score: 10
  • Number of attempts: 1
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: 38
  • Number of attempts: 5
Refactoring useless Method away - 78 entries

Real-life challenge, convert a bunch of ifs to a switch statement

  • Best score: 47
  • Best player score: 53
  • 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: 38
  • Number of attempts: 2
Binary and Increment - 41 entries

Some numbers fun: not only increasing numbers but also increasing binary.

  • Best score: 22
  • Best player score: 40
  • Number of attempts: 4
C to VimDict - 38 entries

Convert a C data structure to a Vimscript dictionary.

  • Best score: 39
  • Best player score: 42
  • Number of attempts: 8
vim1001 - 243 entries

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

  • Best score: 17
  • Best player score: 23
  • 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: 53
  • Number of attempts: 2
Refactor arguments into object argument - 156 entries

A relatively common Javascript refactoring.

  • Best score: 48
  • Best player score: 54
  • 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: 89
  • 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: 54
  • 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: 57
  • Number of attempts: 4
Lower cased and dashed strings - 46 entries

As I have to generate big fixtures files, I wanted to find a way to format input data the way described by start and end files. Especially the lower-cased-and-dashed ids Not so good to find a pure Vim way, that's why I submit this challenge ;)

  • Best score: 59
  • Best player score: 62
  • Number of attempts: 4
Carlos A Henríquez Q
Twitter:

Videogame fan. Guilty for @LagunexDomino for Android and BlackBerry. Love playing sports even though I'm not good. Maracucho.

entered into 102 challenges

contributed 0 challenges