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 - 33715 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 / 7440
  • Number of attempts: 6
Swap values - 4639 entries

Well, swap the values...

  • Best score: 11
  • Best player score: 13
  • Position: #546 / 1273
  • Number of attempts: 6
Wget failed to download redirections - 202 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 / 65
  • Number of attempts: 9
vim = 22 / 7 - 475 entries

pi square vim

  • Best score: 20
  • Best player score: 34
  • Position: #111 / 135
  • Number of attempts: 2
V to the i - 4813 entries

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

  • Best score: 7
  • Best player score: 9
  • Position: #1562 / 1897
  • Number of attempts: 2
Extract argument from function - 2364 entries

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

  • Best score: 13
  • Best player score: 14
  • Position: #314 / 755
  • Number of attempts: 3
That hyphen - 2595 entries

"vim vi improved"

  • Best score: 9
  • Best player score: 11
  • Position: #311 / 701
  • Number of attempts: 2
Just the middle - 11477 entries

Delete the instructions at the top and bottom.

  • Best score: 7
  • Best player score: 8
  • Position: #1617 / 4206
  • Number of attempts: 7
Make HTML List - 1050 entries

Turn the comma separated list into an unordered html list.

  • Best score: 33
  • Best player score: 39
  • Position: #81 / 273
  • Number of attempts: 2
Extended Customer 2 - 49 entries

Format the chars

  • Best score: 47
  • Best player score: 71
  • Position: #10 / 21
  • Number of attempts: 1
Basic renumbering - 5675 entries

Renumbering Basic.

  • Best score: 11
  • Best player score: 18
  • Position: #632 / 1268
  • Number of attempts: 3
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: 38
  • Position: #32 / 63
  • Number of attempts: 2
FoodCritic023: Prefer conditional attributes - 181 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: #29 / 53
  • Number of attempts: 5
Add to end of each line... kinda - 333 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 / 174
  • Number of attempts: 1
underscore_to_camelCase - 173 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: #43 / 82
  • Number of attempts: 1
Fun With The Diagonal - 107 entries

change the lowercase characters on the main diagonal to uppercase

  • Best score: 11
  • Best player score: 11
  • Position: #9 / 81
  • Number of attempts: 1
JSON string rotation - 64 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: #12 / 22
  • Number of attempts: 5
Vice versa - 7937 entries

Little role switching.

  • Best score: 12
  • Best player score: 14
  • Position: #899 / 2136
  • Number of attempts: 2
Free hyphen! - 169 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: #47 / 89
  • Number of attempts: 2
Lower cased and dashed strings - 49 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: #7 / 20
  • Number of attempts: 4
Vim's not included features - 240 entries

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

  • Best score: 23
  • Best player score: 25
  • Position: #28 / 65
  • Number of attempts: 4
Sorting a glossary - 131 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 / 81
  • Number of attempts: 1
comments galore - 1045 entries

Basic comment reformatting

  • Best score: 10
  • Best player score: 11
  • Position: #342 / 424
  • Number of attempts: 1
lipsum lines - 278 entries

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

  • Best score: 28
  • Best player score: 31
  • Position: #48 / 95
  • Number of attempts: 5
Inner hyphens - 136 entries

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

  • Best score: 11
  • Best player score: 12
  • Position: #30 / 82
  • Number of attempts: 1
Replace and keep the case - 437 entries

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

  • Best score: 26
  • Best player score: 29
  • Position: #74 / 118
  • Number of attempts: 4
Scrambled numbers - 807 entries

Four is NOT 1. One is 1.

  • Best score: 18
  • Best player score: 26
  • Position: #125 / 184
  • Number of attempts: 4
Alsa configuration - 513 entries

I'm tweaking my ~/.asoundrc file!

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

Create tokens for bison out of a known list of words

  • Best score: 85
  • Best player score: 89
  • Position: #9 / 18
  • Number of attempts: 1
Separating firstname & lastname - 138 entries

Seperate named with equal tabs.

  • Best score: 19
  • Best player score: 23
  • Position: #23 / 57
  • Number of attempts: 1
Assign numbers to fields - 116 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 / 62
  • Number of attempts: 2
Mirror Symmetry - 822 entries

Add backslashes.

  • Best score: 7
  • Best player score: 12
  • Position: #159 / 269
  • Number of attempts: 1
No naked if allowed! - 39 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: #7 / 17
  • Number of attempts: 1
Binary and Increment - 56 entries

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

  • Best score: 22
  • Best player score: 40
  • Position: #15 / 20
  • Number of attempts: 4
Entries sort - 90 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: #36 / 40
  • Number of attempts: 2
Collect List - 4305 entries

Convert to comma separated list.

  • Best score: 12
  • Best player score: 14
  • Position: #648 / 1191
  • Number of attempts: 3
VimGolfNight - 560 entries

Based on "The name of the game".

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

Sometimes it is better to log with meaningful key

  • Best score: 21
  • Best player score: 24
  • Position: #37 / 88
  • Number of attempts: 6
Space out the alphabet - 1657 entries

Put 3 spaces between adjacent letters.

  • Best score: 15
  • Best player score: 18
  • Position: #206 / 444
  • Number of attempts: 5
remove all lines in first part - 211 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: #50 / 67
  • Number of attempts: 2
Mute the second method of this script - 455 entries

prepend a # infront of every line of the second method

  • Best score: 8
  • Best player score: 10
  • Position: #159 / 239
  • Number of attempts: 1
Winning streak - 135 entries

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

  • Best score: 21
  • Best player score: 26
  • Position: #16 / 51
  • Number of attempts: 2
Sorting database text output - 223 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: #60 / 83
  • Number of attempts: 5
Refactoring useless Method away - 116 entries

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

  • Best score: 47
  • Best player score: 53
  • Position: #13 / 34
  • Number of attempts: 5
Test everything! - 186 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: #16 / 54
  • Number of attempts: 7
Condensed Cases - 804 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: #132 / 247
  • Number of attempts: 1
increment by column in XML - 152 entries

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

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

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

  • Best score: 13
  • Best player score: 14
  • Position: #16 / 64
  • Number of attempts: 6
Happy TvvO - 427 entries

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

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

Convert a C data structure to a Vimscript dictionary.

  • Best score: 39
  • Best player score: 42
  • Position: #9 / 15
  • Number of attempts: 8
range(10) digit rotation - 38 entries

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

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

Oops.

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

Number words are back.

  • Best score: 19
  • Best player score: 30
  • Position: #55 / 69
  • Number of attempts: 3
learn vim in short time - 240 entries

so happy to learn vim.because vim is awesome

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

Implementing the methods of a Java Interface

  • Best score: 33
  • Best player score: 37
  • Position: #9 / 27
  • Number of attempts: 5
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: 23
  • Position: #66 / 110
  • Number of attempts: 1
Roman numerals - 81 entries

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

  • Best score: 17
  • Best player score: 23
  • Position: #19 / 29
  • Number of attempts: 2
-a-b-c- - 3216 entries

Put hyphens everywhere.

  • Best score: 13
  • Best player score: 15
  • Position: #523 / 1138
  • Number of attempts: 2
Count both ways - 1022 entries

Right AND down.

  • Best score: 13
  • Best player score: 16
  • Position: #206 / 354
  • Number of attempts: 3
NBCU Weekly Challenge - Test - 253 entries

Just testing.

  • Best score: 18
  • Best player score: 18
  • Position: #42 / 116
  • Number of attempts: 3
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: #87 / 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: 15
  • Position: #96 / 158
  • Number of attempts: 1
120 Degrees - 493 entries

Rotate that triangle.

  • Best score: 14
  • Best player score: 26
  • Position: #118 / 145
  • Number of attempts: 1
Gray area - 747 entries

It's a golf metaphor or something.

  • Best score: 11
  • Best player score: 13
  • Position: #164 / 271
  • Number of attempts: 4
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: 32
  • Position: #31 / 58
  • Number of attempts: 2
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: 29
  • Position: #23 / 64
  • Number of attempts: 7
Winding path - 122 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: #16 / 42
  • Number of attempts: 3
Neither Fizz nor Buzz - 253 entries

Not your regular increment macro! The gaps are tricky.

  • Best score: 13
  • Best player score: 29
  • Position: #93 / 103
  • Number of attempts: 3
Do you demand a shrubbery? - 1158 entries

Use :redir and crush the emacsgolfers.

  • Best score: 15
  • Best player score: 32
  • Position: #262 / 300
  • Number of attempts: 1
Don't know what this is - 2024 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: #326 / 586
  • Number of attempts: 1
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: 32
  • Position: #117 / 208
  • Number of attempts: 3
Where should I put the Newline? - 881 entries

Help me put the newline.

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

Vim can play tetris too!

  • Best score: 21
  • Best player score: 31
  • Position: #83 / 102
  • Number of attempts: 1
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: 57
  • Position: #12 / 24
  • Number of attempts: 4
Piphilology - 146 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: #40 / 53
  • Number of attempts: 2
Mess in revision history - 1184 entries

Help Joe clean up what Steve has cobbled.

  • Best score: 17
  • Best player score: 27
  • Position: #166 / 250
  • 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: 22
  • Position: #12 / 21
  • Number of attempts: 4
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: 38
  • Position: #16 / 36
  • Number of attempts: 5
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: 123
  • Position: #12 / 33
  • Number of attempts: 4
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: 31
  • Position: #85 / 128
  • Number of attempts: 2
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: 36
  • Position: #63 / 111
  • Number of attempts: 2
Permutations N=4 - 61 entries

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

  • Best score: 25
  • Best player score: 37
  • Position: #13 / 19
  • Number of attempts: 4
A HAPPY NEW YEAR 2014 ! - 10676 entries

A HAPPY NEW YEAR 2014 !

  • Best score: 11
  • Best player score: 11
  • Position: #593 / 3687
  • 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: 64
  • Position: #111 / 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: 12
  • Position: #337 / 518
  • Number of attempts: 3
Untangle my tail, please! - 60 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: #30 / 33
  • Number of attempts: 1
quotes inside quotes - 3165 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: #607 / 1079
  • 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: 25
  • Position: #20 / 30
  • Number of attempts: 4
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: 24
  • Position: #26 / 71
  • Number of attempts: 1
Sort the VimGolf challenges by popularity - 348 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: #69 / 107
  • 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: 54
  • Position: #43 / 78
  • Number of attempts: 1
Words in parens - 12966 entries

We should all ace this, right?

  • Best score: 13
  • Best player score: 14
  • Position: #489 / 3968
  • Number of attempts: 4
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: 53
  • Position: #119 / 136
  • Number of attempts: 2
Assign list - 192 entries

Assign list elements to matrix

  • Best score: 30
  • Best player score: 46
  • Position: #35 / 61
  • Number of attempts: 4
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: 72
  • Position: #33 / 51
  • Number of attempts: 3
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: 18
  • Position: #52 / 59
  • Number of attempts: 3
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: 21
  • Position: #216 / 304
  • Number of attempts: 1
Delete unwanted lines - 419 entries

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

  • Best score: 9
  • Best player score: 9
  • Position: #146 / 230
  • Number of attempts: 2
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: 24
  • Position: #62 / 77
  • Number of attempts: 1
Lookahead and Lookbehind - 70 entries

Look everywhere

  • Best score: 16
  • Best player score: 20
  • Position: #14 / 31
  • Number of attempts: 5
LaTeX to XML Math Delimiters - 48 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: #8 / 20
  • Number of attempts: 2
Refactor arguments into object argument - 166 entries

A relatively common Javascript refactoring.

  • Best score: 48
  • Best player score: 54
  • Position: #14 / 68
  • 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