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]

28790 active golfers, 342940 entries, 491 challenges

Open VimGolf challenges

Levenshtein distance - 39 entries

Compute distance for each pair. Notice that this recursive implementation is very inefficient. Wagner-Fischer algorithm is iterative and much faster. #vimscript

Reformat/Refactor a Golfer Class - 5698 entries

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

Mr. Hacker - 17 entries

Elvin is hacker. He has piece of users database from some social net site. Recently he installed Vim, and he wants to convert CSV DB to specific format `key=value' where `key' is login and `value' is password, but password in DB is encrypted in ROT13. Help him.

switch variable - 4696 entries

how fast can you switch two variable ?

Increment each number - 775 entries

Increment each number individually by one

-a-b-c- - 2932 entries

Put hyphens everywhere.

Put the months in order - 765 entries

Our contractor thought that months should be in alphabetical order. Put them in calendar order please.

Split line with dots - 2025 entries

This line is too long, split it.

Cool or not? - 677 entries

abc trying to be cool or not...

attr_aligner - 3246 entries

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

Two pairs of cluster of letters creates word - 654 entries

Clean and group.

Search and Replace 0 - 4450 entries

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

multiple cursor alternative - 1360 entries

from: https://www.reddit.com/r/vim/comments/6w5pfa/crosspost_from_remacs_how_would_you_do_this_in_vim/

Delete to the end of the current line - 687 entries

Delete to the end of the current line, but keep the character under the cursor.

html paragraph to table - 550 entries

reformat html paragraph to table

quotes inside quotes - 2952 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 :)

That hyphen - 2397 entries

"vim vi improved"

convert yml into java pojo field - 783 entries

How fast vim can create fields for java pojo i.e class declaration referring to a (simple) yml file

From argument to object - 1225 entries

This task typifies those programmers endure while coding. This C-family pseudocode needs a function argument to be repurposed as an object call. Simply search and replace? Repeat a pattern of edits?

Change part of a function name in multiple occurrences - 559 entries

Change the middle part of the function name in multiple places, preferably using the next and dot commands.

Extract argument from function - 2136 entries

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

Reconstruct the actual output from my unit test tool report - 95 entries

When a test fails, my unit test tool reports differences between the actual output and the expected output as follow: - line in the expected output but missing in the actual output are prefixed with a dash - unexpected lines in the actual output are prefixed with a plus sign - comments added by the unit test tool are prefixed with a question mark - common lines are showed `as-is` (well, almost;) From that "diff" format, I would like to reconstruct the actual output.

replacing each line of a block selection - 2704 entries

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

Don't know what this is - 1876 entries

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

Refactor typescript arrow function type - 215 entries

Make arrow function type less verbose and easier to read

comment and uncomment code inline - 947 entries

It's very useful to be able to comment out a block of code in a quick edit. And likewise to uncomment the code. This operation often involves multi-line stanzas and even large blocks. With just line-wise navigation and insert mode this would cost you about 4 keystrokes per line. Master this hole of VimGolf and you'll quickly drop your key count in day to day Vim as well.

Whitespace, empty lines and tabs - 2728 entries

Convert tabs to spaces, strip empty lines and trailing whitespace.

Vertical Limit - 2243 entries

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

Adam's challenge - 889 entries

Change both normal to bold and 4 by 2. Adam Wathan challenge this on twitter . He did it in 11 keystrokes on Sublime.

Space out the alphabet - 1479 entries

Put 3 spaces between adjacent letters.

move titles next to url, in quotes - 406 entries

had trouble with something similar

Missing Library and a Typo - 784 entries

I forgot to add a c library, please add it for me. Also I'm bad at typing so fix my typo too.

Saving the hashes(#) - 1876 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.

ASCII-art Histogram - 239 entries

Create an ASCCI-art histogram for the given numbers. Make sure not to leave trailing whitespaces. Thanks to VimGolf I recently discovered a feature of Vim thAT blew my mind. I'm curious to see what real ninjas make of it ;-)

C# data class to F# record - 48 entries

Converting from C# to F# is not hard, but requires some manual labor. Here you should convert from a C# data class to a F# record.

Switch function arguments - 1888 entries

How to switch two arguments of a function.

Fiddle percentages into real numbers - 762 entries

Get rid of the '%' symbols and shift the decimal place. This is the easier version - all the columns line up.

Align commas - 955 entries

There are 15,000 aligning challenges on vimgolf.com, and they're all exactly the same. I hope this one is a little different.

Quote modules (ver.2) - 112 entries

Complete golang import statement.

Add text at some column - 112 entries

Complete golang struct statement.

Order and join - 811 entries

There's something special about the input order.

Letter case trickery - 1481 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.

Make it more readable - 1812 entries

Insert blank lines to make it more organized and readable

change parenthesis - 219 entries

change the pair of braces into a pair of parentheses

calculations - 187 entries

Complete these (weird) calculations.

comments galore - 924 entries

Basic comment reformatting

Preferably without multi-cursor plugin - 368 entries

Originally asked as question on reddit by kpthunder: https://www.reddit.com/r/vim/comments/9fvsro/what_is_the_most_efficient_way_to_go_about/

Song Transcription Oops - 197 entries

When transcribing vocal music to Canjo Tab you can start by finding the lowest note and assigning that to zero and working your way up from there. However, without fail, I tend to miscount the notes and when I am near done I find a lower note. I mark this with a "z". This means I have to increase all the previous ones by 1. just a sting of numbers :)

Numbering a List - 1764 entries

Pretty simple, number the list.

Remove quotes after first field - 217 entries

Remove the quotes around each field except for the first field.

VimGolf Chatter