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

Make HTML List - 903 entries

Turn the comma separated list into an unordered html list.

  • Best score: 33
  • Best player score: 41
  • Number of attempts: 2
Whitespace, empty lines and tabs - 2557 entries

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

  • Best score: 16
  • Best player score: 28
  • Number of attempts: 4
imports alignment (python) - 577 entries

Align as one import per line.

  • Best score: 17
  • Best player score: 27
  • Number of attempts: 2
Change attribute to getter - 88 entries

Wrap attributes with a getter method.

  • Best score: 24
  • Best player score: 25
  • Number of attempts: 2
Vertical Limit - 2126 entries

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

  • Best score: 21
  • Best player score: 24
  • Number of attempts: 2
Simple, Practical, and Common - 25725 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
Fix the XML - 867 entries

The challenge consists in having a valid xml from an incomplete source.

  • Best score: 18
  • Best player score: 21
  • Number of attempts: 3
Turn a ninja to case-insensitive [Nn][Ii][Nn][Jj][Aa] regexp! - 40 entries

I bumped into this in a dailywtf code: http://pastebin.com/QApa5ycS I didn't want to translate a string whenever I wanted to be [Ss][Aa][Rr][Cc][Aa][Ss][Tt][Ii][Cc] on slack, so I figured a script (python, sed, whatever) would be helpful. Well, or a few vim keystroke!

  • Best score: 18
  • Best player score: 20
  • Number of attempts: 2
Do you demand a shrubbery? - 1016 entries

Use :redir and crush the emacsgolfers.

  • Best score: 15
  • Best player score: 20
  • Number of attempts: 1
Adam's challenge - 804 entries

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

  • Best score: 18
  • Best player score: 19
  • Number of attempts: 5
swap or reverse - 91 entries

Try to swap or reverse the line as needed.

  • Best score: 16
  • Best player score: 19
  • 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: 13
  • Number of attempts: 3
Words in parens - 11172 entries

We should all ace this, right?

  • Best score: 14
  • Best player score: 14
  • Number of attempts: 4
-a-b-c- - 2635 entries

Put hyphens everywhere.

  • Best score: 13
  • Best player score: 13
  • Number of attempts: 3
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: 14
  • Number of attempts: 8
Copy three lines - 2135 entries

If the site is up (by some miracle), make the text under every header identical.

  • Best score: 13
  • Best player score: 18
  • Number of attempts: 4
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: 31
  • Number of attempts: 1
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
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: 9
  • Number of attempts: 4
readability - 285 entries

Make the code readable by adding some spaces

  • Best score: 18
  • Best player score: 19
  • Number of attempts: 1
Search and Replace 0 - 4166 entries

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

  • Best score: 12
  • Best player score: 13
  • Number of attempts: 3
Sort files from hosts - 129 entries

Resume files by host. I hope you enjoy with this challenge

  • Best score: 15
  • Best player score: 18
  • Number of attempts: 1
Separate the lines - 126 entries

Every other line is mixed up. Separate them into their original texts.

  • Best score: 11
  • Best player score: 14
  • Number of attempts: 1
Shuffled numbers - 199 entries

Each number is paired with the number it should follow. That's enough information to put them in order.

  • Best score: 15
  • Best player score: 15
  • Number of attempts: 4
I forgot quotes - 12159 entries

Oops.

  • Best score: 10
  • Best player score: 10
  • Number of attempts: 6
Swap values inside brackets - 1629 entries

Easy challenge.

  • Best score: 14
  • Best player score: 16
  • Number of attempts: 6
Just the middle - 9424 entries

Delete the instructions at the top and bottom.

  • Best score: 7
  • Best player score: 7
  • Number of attempts: 6
Alsa configuration - 471 entries

I'm tweaking my ~/.asoundrc file!

  • Best score: 22
  • Best player score: 26
  • Number of attempts: 5
Wrap text in quotes - 289 entries

All the blocks of text should be wrapped in quotation marks.

  • Best score: 16
  • Best player score: 16
  • Number of attempts: 4
Change the content of a string - 1238 entries

This docstring is a complete lie. Fix it.

  • Best score: 22
  • Best player score: 22
  • Number of attempts: 3
Mirror Symmetry - 701 entries

Add backslashes.

  • Best score: 7
  • Best player score: 7
  • Number of attempts: 6
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: 21
  • Number of attempts: 2
One number per line - 13415 entries

Just give me the numbers.

  • Best score: 14
  • Best player score: 14
  • Number of attempts: 9
Swap values - 3626 entries

Well, swap the values...

  • Best score: 11
  • Best player score: 12
  • Number of attempts: 7
Collect List - 3550 entries

Convert to comma separated list.

  • Best score: 12
  • Best player score: 12
  • Number of attempts: 5
comment and uncomment code inline - 826 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.

  • Best score: 9
  • Best player score: 9
  • Number of attempts: 4
switch variable - 4344 entries

how fast can you switch two variable ?

  • Best score: 11
  • Best player score: 11
  • Number of attempts: 6
replace 2nd column blanks with values in same column if blank - 183 entries

Where ,SOMELOGB and ,SOMELOGC replaces each /r carriage return if 2nd column is blank. The replace only happens if 2nd column is blank though and should replace up to the non blank row.

  • Best score: 15
  • Best player score: 15
  • Number of attempts: 4
V to the i - 3975 entries

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

  • Best score: 7
  • Best player score: 7
  • Number of attempts: 3
Logging with key - 275 entries

Sometimes it is better to log with meaningful key

  • Best score: 21
  • Best player score: 21
  • Number of attempts: 7
remove lines containing the word "reader" - 1877 entries

easy stuff

  • Best score: 9
  • Best player score: 10
  • Number of attempts: 5
That hyphen - 2204 entries

"vim vi improved"

  • Best score: 9
  • Best player score: 9
  • Number of attempts: 7
Delete to the end of the current line - 485 entries

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

  • Best score: 5
  • Best player score: 6
  • Number of attempts: 4
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
Split line with dots - 1865 entries

This line is too long, split it.

  • Best score: 15
  • Best player score: 15
  • Number of attempts: 4
Where should I put the Newline? - 798 entries

Help me put the newline.

  • Best score: 7
  • Best player score: 8
  • Number of attempts: 1
Count both ways - 878 entries

Right AND down.

  • Best score: 13
  • Best player score: 15
  • Number of attempts: 3
For all cases. - 105 entries

In this case... change it! :) Watch the line.

  • Best score: 8
  • Best player score: 8
  • Number of attempts: 2
Stairstep digits - 218 entries

Remove the evens. Double the odds.

  • Best score: 9
  • Best player score: 13
  • Number of attempts: 3
Simple text editing with Vim - 10540 entries

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

  • Best score: 13
  • Best player score: 14
  • Number of attempts: 2
SFD-ROC: vimvimvim - 1294 entries

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

  • Best score: 8
  • Best player score: 8
  • Number of attempts: 5
camel riding - 693 entries

add a prefix on some camelCase variables

  • Best score: 15
  • Best player score: 15
  • Number of attempts: 4
Change part of a function name in multiple occurrences - 438 entries

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

  • Best score: 14
  • Best player score: 15
  • Number of attempts: 2
A HAPPY NEW YEAR 2014 ! - 9607 entries

A HAPPY NEW YEAR 2014 !

  • Best score: 11
  • Best player score: 11
  • Number of attempts: 5
The Cake is a Lie - 1127 entries

Correct the capitalization of each word

  • Best score: 9
  • Best player score: 9
  • Number of attempts: 2
Space out the alphabet - 1382 entries

Put 3 spaces between adjacent letters.

  • Best score: 15
  • Best player score: 15
  • Number of attempts: 4
Vice versa - 6070 entries

Little role switching.

  • Best score: 12
  • Best player score: 15
  • Number of attempts: 1
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: 16
  • Number of attempts: 6
Saving the hashes(#) - 1770 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: 29
  • Number of attempts: 2
replacing each line of a block selection - 2542 entries

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

  • Best score: 18
  • Best player score: 19
  • Number of attempts: 4
Don't know what this is - 1769 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: 16
  • Number of attempts: 4
Gray area - 645 entries

It's a golf metaphor or something.

  • Best score: 11
  • Best player score: 12
  • Number of attempts: 4
Basic renumbering - 4689 entries

Renumbering Basic.

  • Best score: 11
  • Best player score: 14
  • Number of attempts: 5
Align commas - 854 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.

  • Best score: 11
  • Best player score: 17
  • Number of attempts: 1

Contributed Challenges

underscore_to_camelCase - 137 entries

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

Pretty multi-line bash - 194 entries

Bash line continuations are much prettier when they're column aligned.

we’re going to need a bigger bot
Twitter:

programmer, cloud, serverless, vim. my other accounts: @assafketo (nutrition, science), @assafheb (Hebrew)

entered into 64 challenges

contributed 2 challenges