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 - 33385 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
  • Position: #350 / 7364
  • Number of attempts: 6
Swap values - 4543 entries

Well, swap the values...

  • Best score: 11
  • Best player score: 13
  • Position: #540 / 1257
  • Number of attempts: 6
Wget failed to download redirections - 184 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
  • Position: #4 / 63
  • Number of attempts: 9
vim = 22 / 7 - 447 entries

pi square vim

  • Best score: 20
  • Best player score: 34
  • Position: #107 / 131
  • Number of attempts: 2
V to the i - 4751 entries

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

  • Best score: 7
  • Best player score: 9
  • Position: #1549 / 1879
  • Number of attempts: 2
Extract argument from function - 2314 entries

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

  • Best score: 13
  • Best player score: 14
  • Position: #308 / 744
  • Number of attempts: 3
That hyphen - 2556 entries

"vim vi improved"

  • Best score: 9
  • Best player score: 11
  • Position: #307 / 695
  • Number of attempts: 2
Just the middle - 11360 entries

Delete the instructions at the top and bottom.

  • Best score: 7
  • Best player score: 8
  • Position: #1612 / 4164
  • Number of attempts: 7
Make HTML List - 1039 entries

Turn the comma separated list into an unordered html list.

  • Best score: 33
  • Best player score: 39
  • Position: #80 / 271
  • Number of attempts: 2
Extended Customer 2 - 47 entries

Format the chars

  • Best score: 47
  • Best player score: 71
  • Position: #9 / 20
  • Number of attempts: 1
Basic renumbering - 5587 entries

Renumbering Basic.

  • Best score: 11
  • Best player score: 18
  • Position: #624 / 1258
  • Number of attempts: 3
JS notation to Immutable.js notation - 161 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: 38
  • Position: #29 / 60
  • Number of attempts: 2
FoodCritic023: Prefer conditional attributes - 178 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
  • Position: #28 / 51
  • Number of attempts: 5
Add to end of each line... kinda - 325 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
  • Position: #74 / 171
  • Number of attempts: 1
underscore_to_camelCase - 162 entries

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

  • Best score: 14
  • Best player score: 15
  • Position: #41 / 80
  • Number of attempts: 1
Fun With The Diagonal - 103 entries

change the lowercase characters on the main diagonal to uppercase

  • Best score: 11
  • Best player score: 11
  • Position: #9 / 79
  • Number of attempts: 1
JSON string rotation - 55 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
  • Position: #11 / 19
  • Number of attempts: 5
Vice versa - 7803 entries

Little role switching.

  • Best score: 12
  • Best player score: 14
  • Position: #891 / 2100
  • Number of attempts: 2
Free hyphen! - 159 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
  • Position: #45 / 85
  • Number of attempts: 2
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
  • Position: #6 / 18
  • Number of attempts: 4
Vim's not included features - 210 entries

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

  • Best score: 23
  • Best player score: 25
  • Position: #25 / 62
  • Number of attempts: 4
Sorting a glossary - 123 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
  • Position: #36 / 78
  • Number of attempts: 1
comments galore - 998 entries

Basic comment reformatting

  • Best score: 10
  • Best player score: 11
  • Position: #336 / 418
  • Number of attempts: 1
lipsum lines - 252 entries

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

  • Best score: 28
  • Best player score: 31
  • Position: #46 / 91
  • Number of attempts: 5
Inner hyphens - 124 entries

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

  • Best score: 11
  • Best player score: 12
  • Position: #28 / 77
  • Number of attempts: 1
Replace and keep the case - 407 entries

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

  • Best score: 26
  • Best player score: 29
  • Position: #71 / 115
  • Number of attempts: 4
Scrambled numbers - 779 entries

Four is NOT 1. One is 1.

  • Best score: 18
  • Best player score: 26
  • Position: #123 / 182
  • Number of attempts: 4
Alsa configuration - 491 entries

I'm tweaking my ~/.asoundrc file!

  • Best score: 22
  • Best player score: 22
  • Position: #17 / 125
  • Number of attempts: 8
Create bison tokens - 34 entries

Create tokens for bison out of a known list of words

  • Best score: 85
  • Best player score: 89
  • Position: #7 / 16
  • Number of attempts: 1
Separating firstname & lastname - 120 entries

Seperate named with equal tabs.

  • Best score: 19
  • Best player score: 23
  • Position: #21 / 55
  • Number of attempts: 1
Assign numbers to fields - 105 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
  • Position: #17 / 59
  • Number of attempts: 2
Mirror Symmetry - 798 entries

Add backslashes.

  • Best score: 7
  • Best player score: 12
  • Position: #156 / 266
  • Number of attempts: 1
No naked if allowed! - 25 entries

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

  • Best score: 46
  • Best player score: 56
  • Position: #6 / 14
  • Number of attempts: 1
Binary and Increment - 43 entries

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

  • Best score: 22
  • Best player score: 40
  • Position: #12 / 17
  • Number of attempts: 4
Entries sort - 81 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
  • Position: #34 / 38
  • Number of attempts: 2
Collect List - 4264 entries

Convert to comma separated list.

  • Best score: 12
  • Best player score: 14
  • Position: #644 / 1186
  • Number of attempts: 3
VimGolfNight - 536 entries

Based on "The name of the game".

  • Best score: 12
  • Best player score: 12
  • Position: #206 / 343
  • Number of attempts: 2
Logging with key - 301 entries

Sometimes it is better to log with meaningful key

  • Best score: 21
  • Best player score: 24
  • Position: #35 / 86
  • Number of attempts: 6
Space out the alphabet - 1627 entries

Put 3 spaces between adjacent letters.

  • Best score: 15
  • Best player score: 18
  • Position: #204 / 440
  • Number of attempts: 5
remove all lines in first part - 190 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
  • Position: #48 / 65
  • Number of attempts: 2
Mute the second method of this script - 447 entries

prepend a # infront of every line of the second method

  • Best score: 9
  • Best player score: 10
  • Position: #157 / 237
  • Number of attempts: 1
Winning streak - 124 entries

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

  • Best score: 21
  • Best player score: 26
  • Position: #15 / 49
  • Number of attempts: 2
Sorting database text output - 219 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
  • Position: #59 / 81
  • Number of attempts: 5
Refactoring useless Method away - 91 entries

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

  • Best score: 47
  • Best player score: 53
  • Position: #11 / 32
  • Number of attempts: 5
Test everything! - 162 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
  • Position: #14 / 52
  • Number of attempts: 7
Condensed Cases - 788 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
  • Position: #129 / 242
  • Number of attempts: 1
increment by column in XML - 146 entries

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

  • Best score: 19
  • Best player score: 20
  • Position: #20 / 53
  • Number of attempts: 6
Pretty format for variable declarations - 155 entries

Project standards demand the equal signs must be aligned for better readability.

  • Best score: 13
  • Best player score: 14
  • Position: #14 / 62
  • Number of attempts: 6
Happy TvvO - 407 entries

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

  • Best score: 12
  • Best player score: 12
  • Position: #42 / 201
  • Number of attempts: 3
C to VimDict - 46 entries

Convert a C data structure to a Vimscript dictionary.

  • Best score: 39
  • Best player score: 42
  • Position: #7 / 13
  • Number of attempts: 8
range(10) digit rotation - 32 entries

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

  • Best score: 18
  • Best player score: 18
  • Position: #8 / 20
  • Number of attempts: 3
I forgot quotes - 15931 entries

Oops.

  • Best score: 10
  • Best player score: 10
  • Position: #62 / 4161
  • Number of attempts: 4
Shift down - 193 entries

Number words are back.

  • Best score: 19
  • Best player score: 30
  • Position: #53 / 67
  • Number of attempts: 3
learn vim in short time - 232 entries

so happy to learn vim.because vim is awesome

  • Best score: 8
  • Best player score: 8
  • Position: #57 / 158
  • Number of attempts: 1
Replace Parameter with Explicit Methods - 61 entries

Implementing the methods of a Java Interface

  • Best score: 33
  • Best player score: 37
  • Position: #7 / 25
  • Number of attempts: 5
vim1001 - 275 entries

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

  • Best score: 17
  • Best player score: 23
  • Position: #64 / 107
  • Number of attempts: 1
Roman numerals - 68 entries

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

  • Best score: 17
  • Best player score: 23
  • Position: #17 / 27
  • Number of attempts: 2
-a-b-c- - 3176 entries

Put hyphens everywhere.

  • Best score: 13
  • Best player score: 15
  • Position: #519 / 1129
  • Number of attempts: 2
Count both ways - 1001 entries

Right AND down.

  • Best score: 13
  • Best player score: 16
  • Position: #204 / 351
  • Number of attempts: 3
NBCU Weekly Challenge - Test - 243 entries

Just testing.

  • Best score: 18
  • Best player score: 18
  • Position: #42 / 114
  • Number of attempts: 3
Change name of a variable - 169 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: #87 / 132
  • Number of attempts: 1
Lisp Condense - 438 entries

Reduce 4 cons selection operations down to one function call.

  • Best score: 13
  • Best player score: 15
  • Position: #93 / 154
  • Number of attempts: 1
120 Degrees - 468 entries

Rotate that triangle.

  • Best score: 14
  • Best player score: 26
  • Position: #116 / 143
  • Number of attempts: 1
Gray area - 732 entries

It's a golf metaphor or something.

  • Best score: 11
  • Best player score: 13
  • Position: #162 / 268
  • Number of attempts: 4
NBCU Weekly Challenge - #0 - 125 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
  • Position: #29 / 56
  • Number of attempts: 2
Refactor static member invocation - 198 entries

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

  • Best score: 28
  • Best player score: 29
  • Position: #22 / 63
  • Number of attempts: 7
Winding path - 93 entries

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

  • Best score: 27
  • Best player score: 44
  • Position: #14 / 40
  • Number of attempts: 3
Neither Fizz nor Buzz - 226 entries

Not your regular increment macro! The gaps are tricky.

  • Best score: 13
  • Best player score: 29
  • Position: #90 / 99
  • Number of attempts: 3
Do you demand a shrubbery? - 1120 entries

Use :redir and crush the emacsgolfers.

  • Best score: 15
  • Best player score: 32
  • Position: #257 / 293
  • Number of attempts: 1
Don't know what this is - 1978 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
  • Position: #322 / 578
  • Number of attempts: 1
Two become one - 710 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
  • Position: #116 / 205
  • Number of attempts: 3
Where should I put the Newline? - 863 entries

Help me put the newline.

  • Best score: 7
  • Best player score: 8
  • Position: #329 / 431
  • Number of attempts: 2
Vim tetris - 352 entries

Vim can play tetris too!

  • Best score: 21
  • Best player score: 31
  • Position: #82 / 101
  • Number of attempts: 1
Five Pillars - 62 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
  • Position: #11 / 23
  • Number of attempts: 4
Piphilology - 131 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
  • Position: #39 / 51
  • Number of attempts: 2
Mess in revision history - 1160 entries

Help Joe clean up what Steve has cobbled.

  • Best score: 17
  • Best player score: 27
  • Position: #163 / 246
  • Number of attempts: 1
Carriage return - 42 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
  • Position: #12 / 20
  • Number of attempts: 4
HTML formatting: vertical alignment for readability - 63 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
  • Position: #14 / 33
  • Number of attempts: 5
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
  • Position: #11 / 32
  • Number of attempts: 4
Going underground.... - 339 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
  • Position: #82 / 125
  • Number of attempts: 2
Split the words - 356 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
  • Position: #61 / 108
  • Number of attempts: 2
Permutations N=4 - 60 entries

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

  • Best score: 25
  • Best player score: 37
  • Position: #12 / 18
  • Number of attempts: 4
A HAPPY NEW YEAR 2014 ! - 10624 entries

A HAPPY NEW YEAR 2014 !

  • Best score: 11
  • Best player score: 11
  • Position: #593 / 3666
  • Number of attempts: 4
Counting in binary - 477 entries

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

  • Best score: 16
  • Best player score: 64
  • Position: #107 / 113
  • Number of attempts: 2
Letter case trickery - 1594 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
  • Position: #333 / 511
  • Number of attempts: 3
Untangle my tail, please! - 57 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
  • Position: #29 / 31
  • Number of attempts: 1
quotes inside quotes - 3125 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: #604 / 1072
  • Number of attempts: 2
Hanging Indent for Footnotes - 69 entries

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

  • Best score: 17
  • Best player score: 25
  • Position: #19 / 28
  • Number of attempts: 4
Top X - 191 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
  • Position: #24 / 69
  • Number of attempts: 1
Sort the VimGolf challenges by popularity - 345 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
  • Position: #68 / 105
  • Number of attempts: 3
Number an outline - 249 entries

The indent and words are right, but the numbers are all wrong.

  • Best score: 25
  • Best player score: 54
  • Position: #41 / 75
  • Number of attempts: 1
Words in parens - 12854 entries

We should all ace this, right?

  • Best score: 13
  • Best player score: 14
  • Position: #481 / 3945
  • Number of attempts: 4
Pairs of numbers - 360 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
  • Position: #117 / 133
  • Number of attempts: 2
Assign list - 169 entries

Assign list elements to matrix

  • Best score: 30
  • Best player score: 46
  • Position: #33 / 59
  • Number of attempts: 4
Draw the Go board - 140 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
  • Position: #31 / 48
  • Number of attempts: 3
paste indent correction - JS - 102 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
  • Position: #50 / 57
  • Number of attempts: 3
Hole-in-one - 1012 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
  • Position: #215 / 302
  • Number of attempts: 1
Delete unwanted lines - 396 entries

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

  • Best score: 9
  • Best player score: 9
  • Position: #146 / 225
  • Number of attempts: 2
Parsing with CSV: Unify lines and result. - 165 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
  • Position: #59 / 73
  • Number of attempts: 1
Lookahead and Lookbehind - 67 entries

Look everywhere

  • Best score: 16
  • Best player score: 20
  • Position: #13 / 29
  • Number of attempts: 5
LaTeX to XML Math Delimiters - 40 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
  • Position: #7 / 18
  • Number of attempts: 2
Refactor arguments into object argument - 161 entries

A relatively common Javascript refactoring.

  • Best score: 48
  • Best player score: 54
  • Position: #13 / 65
  • Number of attempts: 2
Carlos A Henríquez Q
Twitter:

Videogame fan. Learning how to play Cuatro Venezolano. Love playing sports even though I'm not good. Maracucho.

entered into 102 challenges

contributed 0 challenges