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 - 33483 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: #971 / 7384
  • Number of attempts: 12
Swap values - 4554 entries

Well, swap the values...

  • Best score: 11
  • Best player score: 15
  • Position: #876 / 1259
  • Number of attempts: 2
One number per line - 18673 entries

Just give me the numbers.

  • Best score: 14
  • Best player score: 19
  • Position: #1604 / 3852
  • Number of attempts: 4
Wget failed to download redirections - 185 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: 18
  • Position: #32 / 64
  • Number of attempts: 4
Separate the lines - 176 entries

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

  • Best score: 11
  • Best player score: 14
  • Position: #64 / 90
  • Number of attempts: 1
Split line with dots - 2131 entries

This line is too long, split it.

  • Best score: 15
  • Best player score: 17
  • Position: #241 / 633
  • Number of attempts: 2
multiple cursor alternative - 1488 entries

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

  • Best score: 19
  • Best player score: 25
  • Position: #301 / 378
  • Number of attempts: 4
From argument to object - 1481 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?

  • Best score: 17
  • Best player score: 22
  • Position: #384 / 453
  • Number of attempts: 1
Every other line - 2902 entries

AaAaAaA

  • Best score: 12
  • Best player score: 15
  • Position: #337 / 702
  • Number of attempts: 5
Extract argument from function - 2337 entries

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

  • Best score: 13
  • Best player score: 17
  • Position: #617 / 750
  • Number of attempts: 1
Search and Replace 0 - 4851 entries

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

  • Best score: 12
  • Best player score: 12
  • Position: #440 / 1604
  • Number of attempts: 3
That hyphen - 2572 entries

"vim vi improved"

  • Best score: 9
  • Best player score: 9
  • Position: #123 / 698
  • Number of attempts: 5
comment and uncomment code inline - 1074 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: 10
  • Position: #171 / 316
  • Number of attempts: 3
Just the middle - 11380 entries

Delete the instructions at the top and bottom.

  • Best score: 7
  • Best player score: 8
  • Position: #2182 / 4174
  • Number of attempts: 1
Team names - 1812 entries

The team names are misspelled.

  • Best score: 16
  • Best player score: 16
  • Position: #1 / 585
  • Number of attempts: 5
Make HTML List - 1050 entries

Turn the comma separated list into an unordered html list.

  • Best score: 33
  • Best player score: 46
  • Position: #138 / 273
  • Number of attempts: 4
Un"finnish"ed Work - 115 entries

Replace å by a, ä by a and ö by o.

  • Best score: 14
  • Best player score: 15
  • Position: #30 / 59
  • Number of attempts: 1
Todo list specification - 389 entries

The every item on the todo list must be done today. Modify the list to reflect that.

  • Best score: 37
  • Best player score: 37
  • Position: #14 / 178
  • Number of attempts: 2
Sort yaml structures alphabetically by root key names - 39 entries

sometimes we want to sort structures alphabetically in yaml files

  • Best score: 31
  • Best player score: 91
  • Position: #19 / 19
  • Number of attempts: 1
Text to HTML Table - 174 entries

Turn the plain text table to an HTML table.

  • Best score: 52
  • Best player score: 52
  • Position: #13 / 51
  • Number of attempts: 4
Python Hello World! Reformatting - 955 entries

A novice Python using prints Hello World! and a pro shows him different way. Using vim to get into pro style from novice, win the challenge.

  • Best score: 39
  • Best player score: 41
  • Position: #69 / 371
  • Number of attempts: 5
Remember VimGolf Rules ! - 259 entries

Rules, ... and don't forget !

  • Best score: 7
  • Best player score: 8
  • Position: #64 / 139
  • Number of attempts: 1
Back to the roots - 54 entries

Johnny has a file with more integers. He wants to change each number with its square root. Can you help him?

  • Best score: 21
  • Best player score: 23
  • Position: #19 / 37
  • Number of attempts: 1
Missing Library and a Typo - 860 entries

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

  • Best score: 14
  • Best player score: 23
  • Position: #180 / 211
  • Number of attempts: 2
Basic renumbering - 5605 entries

Renumbering Basic.

  • Best score: 11
  • Best player score: 16
  • Position: #552 / 1260
  • Number of attempts: 5
Simple addition - 312 entries

The right side of the equation is already there. We just need the left one now.

  • Best score: 12
  • Best player score: 15
  • Position: #98 / 118
  • Number of attempts: 1
Hidden Message - 78 entries

Find the hidden message and replace all other characters with spaces.

  • Best score: 33
  • Best player score: 45
  • Position: #22 / 29
  • Number of attempts: 1
create arrows in a list - 106 entries

Add arrow at same distance

  • Best score: 10
  • Best player score: 10
  • Position: #40 / 71
  • Number of attempts: 1
Adam's challenge - 958 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: 18
  • Position: #35 / 267
  • Number of attempts: 5
Create Leading Zeros - 239 entries

Create leading zeros only for id columns. Please use generic approach!

  • Best score: 23
  • Best player score: 44
  • Position: #61 / 81
  • Number of attempts: 2
42-header - 39 entries

Rush 42mexican-standoff at 42 school

  • Best score: 22
  • Best player score: 22
  • Position: #3 / 15
  • Number of attempts: 7
Create a table - 332 entries

Convert the given input into a formatted table

  • Best score: 16
  • Best player score: 18
  • Position: #68 / 105
  • Number of attempts: 2
Fiddle percentages into real numbers - 841 entries

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

  • Best score: 13
  • Best player score: 13
  • Position: #82 / 288
  • Number of attempts: 2
Combines all items - 307 entries

For each line that starts with the same number I want to combine its contents

  • Best score: 9
  • Best player score: 10
  • Position: #122 / 139
  • Number of attempts: 1
replace 2nd column blanks with values in same column if blank - 232 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: 18
  • Position: #65 / 82
  • Number of attempts: 1
Vice versa - 7865 entries

Little role switching.

  • Best score: 12
  • Best player score: 13
  • Position: #728 / 2114
  • Number of attempts: 5
Pretty multi-line bash - 219 entries

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

  • Best score: 15
  • Best player score: 21
  • Position: #43 / 76
  • Number of attempts: 3
C Reformatting - 689 entries

You may use Visual mode... or not. #uppercase

  • Best score: 30
  • Best player score: 47
  • Position: #80 / 162
  • Number of attempts: 4
Sorting a glossary - 127 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: #43 / 80
  • Number of attempts: 2
Order and join - 965 entries

There's something special about the input order.

  • Best score: 10
  • Best player score: 11
  • Position: #113 / 258
  • Number of attempts: 4
Paragraph breaks - 509 entries

Swap the blank lines and the aaa lines.

  • Best score: 10
  • Best player score: 11
  • Position: #74 / 166
  • Number of attempts: 2
comments galore - 1017 entries

Basic comment reformatting

  • Best score: 10
  • Best player score: 10
  • Position: #164 / 421
  • Number of attempts: 2
Replace and keep the case - 415 entries

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

  • Best score: 26
  • Best player score: 29
  • Position: #76 / 117
  • Number of attempts: 3
Change attribute to getter - 134 entries

Wrap attributes with a getter method.

  • Best score: 24
  • Best player score: 25
  • Position: #39 / 58
  • Number of attempts: 2
Scrambled numbers - 780 entries

Four is NOT 1. One is 1.

  • Best score: 18
  • Best player score: 23
  • Position: #87 / 183
  • Number of attempts: 6
Alsa configuration - 502 entries

I'm tweaking my ~/.asoundrc file!

  • Best score: 22
  • Best player score: 23
  • Position: #58 / 127
  • Number of attempts: 7
Align commas - 1063 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
  • Position: #163 / 243
  • Number of attempts: 4
Manual SQL - 136 entries

Change select and insert queries to simulate inserting a new record.

  • Best score: 48
  • Best player score: 65
  • Position: #28 / 49
  • Number of attempts: 5
mp3 - Cutlist - 30 entries

An audio CD was accidentally ripped into one single mp3 file. A dummy cue-file now needs to be filled out with the correct values to get single mp3 files.

  • Best score: 65
  • Best player score: 115
  • Position: #7 / 13
  • Number of attempts: 1
Hello ${world} - 300 entries

Migrate a JavaScript String from concatenation to ES6 interpolation.

  • Best score: 24
  • Best player score: 27
  • Position: #54 / 95
  • Number of attempts: 4
Array transposition - 2407 entries

Transpose two arrays into one.

  • Best score: 16
  • Best player score: 18
  • Position: #190 / 445
  • Number of attempts: 10
Mirror Symmetry - 812 entries

Add backslashes.

  • Best score: 7
  • Best player score: 13
  • Position: #214 / 268
  • Number of attempts: 2
From A to B - 575 entries

Mirror and change this text block

  • Best score: 16
  • Best player score: 21
  • Position: #123 / 157
  • Number of attempts: 3
Collect List - 4267 entries

Convert to comma separated list.

  • Best score: 12
  • Best player score: 12
  • Position: #210 / 1188
  • Number of attempts: 9
camel riding - 775 entries

add a prefix on some camelCase variables

  • Best score: 15
  • Best player score: 18
  • Position: #237 / 277
  • Number of attempts: 1
readability - 315 entries

Make the code readable by adding some spaces

  • Best score: 18
  • Best player score: 18
  • Position: #70 / 150
  • Number of attempts: 3
Interleave lines - 159 entries

This is some kind of « paste -d'\n' c b a ». There are many ways to achieve this.. just find the shortest!

  • Best score: 17
  • Best player score: 35
  • Position: #46 / 59
  • Number of attempts: 4
Space out the alphabet - 1630 entries

Put 3 spaces between adjacent letters.

  • Best score: 15
  • Best player score: 17
  • Position: #193 / 442
  • Number of attempts: 4
remove all lines in first part - 197 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: 15
  • Position: #30 / 66
  • Number of attempts: 4
Merge blank lines and properly capitalize - 82 entries

Here you need complete 2 tasks: 1. Remove all unwanted continuous blank lines and leave only 1 blank line between paragraphs. 2. Properly capitalize the sentences.

  • Best score: 21
  • Best player score: 43
  • Position: #18 / 24
  • Number of attempts: 1
Fix the XML - 1000 entries

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

  • Best score: 18
  • Best player score: 32
  • Position: #259 / 287
  • Number of attempts: 1
Line 'em up! - 396 entries

It can be so hard to keep everything neatly lined-up. Somebody clearly hasn't bothered here. Tidy it up, please!

  • Best score: 17
  • Best player score: 30
  • Position: #93 / 112
  • Number of attempts: 1
Mute the second method of this script - 449 entries

prepend a # infront of every line of the second method

  • Best score: 8
  • Best player score: 9
  • Position: #111 / 238
  • Number of attempts: 3
Condensed Cases - 794 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
  • Position: #93 / 244
  • Number of attempts: 3
increment by column in XML - 147 entries

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

  • Best score: 19
  • Best player score: 26
  • Position: #39 / 54
  • Number of attempts: 2
Pretty format for variable declarations - 156 entries

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

  • Best score: 13
  • Best player score: 19
  • Position: #51 / 63
  • Number of attempts: 2
Happy TvvO - 417 entries

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

  • Best score: 12
  • Best player score: 12
  • Position: #111 / 204
  • Number of attempts: 4
I forgot quotes - 15946 entries

Oops.

  • Best score: 10
  • Best player score: 12
  • Position: #1281 / 4166
  • Number of attempts: 2
-a-b-c- - 3183 entries

Put hyphens everywhere.

  • Best score: 13
  • Best player score: 13
  • Position: #160 / 1132
  • Number of attempts: 4
Suffix sort - 255 entries

Sort from the end of the line, as if the letters in each line were reversed.

  • Best score: 19
  • Best player score: 24
  • Position: #36 / 66
  • Number of attempts: 3
NBCU Weekly Challenge - Test - 244 entries

Just testing.

  • Best score: 18
  • Best player score: 18
  • Position: #52 / 115
  • Number of attempts: 2
Gray area - 745 entries

It's a golf metaphor or something.

  • Best score: 11
  • Best player score: 11
  • Position: #16 / 270
  • Number of attempts: 5
Don't know what this is - 1996 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: 12
  • Position: #211 / 581
  • Number of attempts: 10
Mess in revision history - 1183 entries

Help Joe clean up what Steve has cobbled.

  • Best score: 17
  • Best player score: 30
  • Position: #205 / 249
  • Number of attempts: 1
A HAPPY NEW YEAR 2014 ! - 10652 entries

A HAPPY NEW YEAR 2014 !

  • Best score: 11
  • Best player score: 11
  • Position: #954 / 3677
  • Number of attempts: 4
attr_aligner - 3454 entries

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

  • Best score: 19
  • Best player score: 23
  • Position: #227 / 695
  • Number of attempts: 10
Letter case trickery - 1598 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: #346 / 514
  • Number of attempts: 5
quotes inside quotes - 3128 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: 15
  • Position: #474 / 1073
  • Number of attempts: 2
Words in parens - 12868 entries

We should all ace this, right?

  • Best score: 13
  • Best player score: 16
  • Position: #2308 / 3950
  • Number of attempts: 1
Block Fun 1 - 190 entries

Manipulate the columns to produce desired result.

  • Best score: 14
  • Best player score: 25
  • Position: #64 / 74
  • Number of attempts: 3
abcd > a b c d - 282 entries

transform the single spaces into 4 spaces repeat for each line

  • Best score: 15
  • Best player score: 15
  • Position: #163 / 220
  • Number of attempts: 1
NATO phonetic alphabet - 506 entries

Transform the series of words into a list.

  • Best score: 19
  • Best player score: 22
  • Position: #118 / 194
  • Number of attempts: 1
Extract text from xml - 110 entries

Extract text from xml file (ignoring commented out elements) and create a one line regex.

  • Best score: 28
  • Best player score: 28
  • Position: #5 / 45
  • Number of attempts: 5
SFD-ROC: vimvimvim - 1594 entries

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

  • Best score: 8
  • Best player score: 9
  • Position: #235 / 443
  • Number of attempts: 5
Saving the hashes(#) - 2008 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: 25
  • Position: #180 / 476
  • Number of attempts: 6
Convert pandoc unordered list to a numbered list - 166 entries

I know it's possible to use #. in pandoc to auto-generate numbered lists, but then it's not easy to tell how many items there are when reading it in Markdown. How fast can you make the switch?

  • Best score: 20
  • Best player score: 48
  • Position: #53 / 57
  • Number of attempts: 1
Let's play some Ivmgolf - 1096 entries

Oops, I spelled that wrong.

  • Best score: 7
  • Best player score: 9
  • Position: #304 / 442
  • Number of attempts: 2
Enharmonic Equivalents - 57 entries

Transform # and b to digraphs

  • Best score: 18
  • Best player score: 18
  • Position: #12 / 36
  • Number of attempts: 2
Vertical Limit - 2487 entries

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

  • Best score: 21
  • Best player score: 25
  • Position: #365 / 748
  • Number of attempts: 7
replacing each line of a block selection - 2966 entries

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

  • Best score: 18
  • Best player score: 21
  • Position: #396 / 772
  • Number of attempts: 4
Switch function arguments - 2085 entries

How to switch two arguments of a function.

  • Best score: 11
  • Best player score: 12
  • Position: #294 / 653
  • Number of attempts: 3
Append semicolon after expressions - 1023 entries

Some lines need the semicolon, some don't.

  • Best score: 11
  • Best player score: 12
  • Position: #235 / 410
  • Number of attempts: 5
Reverse and double space - 498 entries

Reverse the order of the given lines and double space everything

  • Best score: 14
  • Best player score: 15
  • Position: #82 / 197
  • Number of attempts: 4
Remove semicolons after expressions - 639 entries

A follow-up for http://vimgolf.com/challenges/4fc9d767d3a0d4000100000e.

  • Best score: 6
  • Best player score: 8
  • Position: #223 / 261
  • Number of attempts: 2
switch variable - 5045 entries

how fast can you switch two variable ?

  • Best score: 11
  • Best player score: 12
  • Position: #889 / 1742
  • Number of attempts: 6
Make it more readable - 1955 entries

Insert blank lines to make it more organized and readable

  • Best score: 13
  • Best player score: 17
  • Position: #476 / 643
  • Number of attempts: 4
It'ss tooo coold too typpe todaay - 222 entries

My hands are numb with cold. It's hard to type correctly.

  • Best score: 16
  • Best player score: 23
  • Position: #66 / 97
  • Number of attempts: 2
Numbering a List - 1869 entries

Pretty simple, number the list.

  • Best score: 13
  • Best player score: 13
  • Position: #24 / 646
  • Number of attempts: 7
Ruby 1.9 hashes - 1225 entries

Rubyists talk about being cutting edge but how many are using 1.9 in production? Time to convert those verbose 1.8 hashes in to symbolic, succinct 1.9 beauties!

  • Best score: 12
  • Best player score: 12
  • Position: #82 / 402
  • Number of attempts: 7
Shebangs for all - 1917 entries

We've all seen or used a shebang once or twice. Ditch the specific paths and leave just a dynamic Ruby and Python bath behind.

  • Best score: 11
  • Best player score: 18
  • Position: #372 / 502
  • Number of attempts: 3
A Simple One - 1009 entries

Here is a very simple one - just to illustrate/introduce a vim feature that some people seem to miss...

  • Best score: 9
  • Best player score: 9
  • Position: #456 / 648
  • Number of attempts: 1
Ruby 1.9 compat - 610 entries

Remember when Ruby supported `when <expr> :`? Well, it doesn't in 1.9, so let's make sure we use `then`, without ruining our lovely new hash syntax!

  • Best score: 14
  • Best player score: 15
  • Position: #112 / 230
  • Number of attempts: 5
Reverse Simple Deletion - 834 entries

You did the simple deletion, now reverse it.

  • Best score: 11
  • Best player score: 12
  • Position: #323 / 455
  • Number of attempts: 2
Increment, increment, increment.... - 668 entries

Vim likes macros

  • Best score: 10
  • Best player score: 12
  • Position: #325 / 404
  • Number of attempts: 2
The Cake is a Lie - 1301 entries

Correct the capitalization of each word

  • Best score: 9
  • Best player score: 9
  • Position: #236 / 517
  • Number of attempts: 2
Make Fancy Header - 1024 entries

Make the header text stand out with surrounding asterisks

  • Best score: 15
  • Best player score: 16
  • Position: #111 / 340
  • Number of attempts: 3
Reverse characters in a line - 732 entries

You have everything you need, just not in the right order. Mastermind would give you 26 white pegs.

  • Best score: 12
  • Best player score: 13
  • Position: #71 / 257
  • Number of attempts: 6
Reformat most common surnames - 671 entries

Reformat copy-pasted table into a list of the most common surnames

  • Best score: 23
  • Best player score: 42
  • Position: #164 / 202
  • Number of attempts: 1
Change the content of a string - 1502 entries

This docstring is a complete lie. Fix it.

  • Best score: 22
  • Best player score: 22
  • Position: #158 / 567
  • Number of attempts: 5
Sort and add attributes - 1369 entries

Sort the states and add the attribute country to each record.

  • Best score: 33
  • Best player score: 34
  • Position: #353 / 542
  • Number of attempts: 2
Reconstruct the Sentence - 1436 entries

Get the sentence back in the proper order, remove duplicate lines, and then combine the separate lines into one.

  • Best score: 20
  • Best player score: 21
  • Position: #223 / 397
  • Number of attempts: 4
Whitespace, empty lines and tabs - 3508 entries

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

  • Best score: 16
  • Best player score: 31
  • Position: #542 / 758
  • Number of attempts: 1
Flodder-challenge - 1176 entries

Replace the text the most efficient and win!

  • Best score: 27
  • Best player score: 33
  • Position: #109 / 321
  • Number of attempts: 4
Reformat/Refactor a Golfer Class - 6749 entries

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

  • Best score: 31
  • Best player score: 37
  • Position: #545 / 1652
  • Number of attempts: 2

Contributed Challenges

Add Go XML to structure tags - 153 entries

The Go programming language can directly map XML to structure fields. Add the correct XML tag after each field.

Ben Hill
Twitter:

entered into 114 challenges

contributed 1 challenges