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

Many duplicates - 589 entries

Quick and easy

  • Best score: 7
  • Best player score: 8
  • Position: #70 / 207
  • Number of attempts: 1
delete swap - 734 entries

delete all swap

  • Best score: 5
  • Best player score: 5
  • Position: #51 / 250
  • Number of attempts: 1
hello-world-vimgolf - 1758 entries

Simple number generation

  • Best score: 10
  • Best player score: 11
  • Position: #238 / 505
  • Number of attempts: 2
Making 3 line function a one liner. - 194 entries

Simple challenge for frequent action while programming.

  • Best score: 4
  • Best player score: 4
  • Position: #58 / 127
  • Number of attempts: 1
Modernise code - 994 entries

Modernise and clean up some C++ code.

  • Best score: 34
  • Best player score: 35
  • Position: #70 / 224
  • Number of attempts: 3
swap number pairs - 1664 entries

Swap the numbers in a bunch of 2-element arrays.

  • Best score: 16
  • Best player score: 17
  • Position: #85 / 311
  • Number of attempts: 4
Python: Def to Lambda - 392 entries

LAMBDA!!!

  • Best score: 19
  • Best player score: 19
  • Position: #42 / 135
  • Number of attempts: 4
Rural Post - 4156 entries

Simple challenge to remove all but the post code on each line

  • Best score: 9
  • Best player score: 10
  • Position: #406 / 1030
  • Number of attempts: 3
Satisfy the go linter - 2031 entries

You just came up with this briliant go vars package. But dang, you forgot to add comments to the exported variables. Can you add a comment over each variable with a TODO-placeholder?

  • Best score: 20
  • Best player score: 21
  • Position: #165 / 412
  • Number of attempts: 7
Add quotes to ansible playbook - 822 entries

You created an ansible playbook, but forgot to add quotes. Can you fix it?

  • Best score: 8
  • Best player score: 9
  • Position: #156 / 258
  • Number of attempts: 4
Multiline to Single Line - 552 entries

Convert a multiline, indented file to a single line with no whitespace

  • Best score: 5
  • Best player score: 5
  • Position: #149 / 248
  • Number of attempts: 1
xrandr outputs and dashes - 613 entries

uh oh, different video drivers identify display outputs with more dashes. Quick, need to change this xrandr script!

  • Best score: 12
  • Best player score: 12
  • Position: #117 / 199
  • Number of attempts: 4
From a Thunderlink to a Markdown link - 711 entries

ThunderLinks are durable hyperlinks to specific email messages generated from Thunderbird in HTML format. Leverage the power of vim to make them suitable for a markdown-formatted file.

  • Best score: 18
  • Best player score: 18
  • Position: #46 / 158
  • Number of attempts: 9
Yo To Hello - 1066 entries

Simply Turn Yo To Hello

  • Best score: 10
  • Best player score: 10
  • Position: #329 / 489
  • Number of attempts: 4
Simple, Practical, and Common - 33029 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: 23
  • Position: #2768 / 7290
  • Number of attempts: 6
Swap values - 4484 entries

Well, swap the values...

  • Best score: 11
  • Best player score: 12
  • Position: #515 / 1245
  • Number of attempts: 5
prepend * to every non-blank line - 6061 entries

Prepend an asterisk to every non-blank line in the input file.

  • Best score: 10
  • Best player score: 11
  • Position: #708 / 1481
  • Number of attempts: 3
One number per line - 18439 entries

Just give me the numbers.

  • Best score: 14
  • Best player score: 14
  • Position: #736 / 3802
  • Number of attempts: 6
vim = 22 / 7 - 424 entries

pi square vim

  • Best score: 20
  • Best player score: 21
  • Position: #49 / 130
  • Number of attempts: 7
Swap values inside brackets - 2440 entries

Easy challenge.

  • Best score: 14
  • Best player score: 15
  • Position: #208 / 563
  • Number of attempts: 10
Unsemantic linewrapping - 849 entries

[Inspired by a blog post I read: https://scott.mn/2014/02/21/semantic_linewrapping/. Text adapted.] Sometimes when editing a Markdown file, I wrap the lines semantically. Instead of inserting a newline at 70 columns (or whatever), or making paragraphs one long line, I put in newlines at a point that seems logical to me. This may seem silly, but it produces better diffs. Semantic linewrapping also makes editing snappier. I can delete, edit or insert sentences easily using linewise operations. Code-oriented text editors like Vim and [REDACTED] are really good at this kind of manipulation. Editing text that hasn't been wrapped semantically is a pain, though:

  • Best score: 9
  • Best player score: 10
  • Position: #144 / 215
  • Number of attempts: 2
V to the i - 4647 entries

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

  • Best score: 7
  • Best player score: 8
  • Position: #1464 / 1861
  • Number of attempts: 2
Applying same text modification in several lines - 2768 entries

Remove identical text at the beginning of several lines and the closing parenthesis.

  • Best score: 12
  • Best player score: 13
  • Position: #252 / 821
  • Number of attempts: 2
SCREAMING_SNAKE_CASE to Title Case - 1123 entries

Convert strings in SCREAMING_SNAKE_CASE to Title Case. Examples: EMPLOYEE_NAME -> Employee Name REVENUE_YEAR_TO_DATE -> Revenue Year To Date SALARY -> Salary

  • Best score: 19
  • Best player score: 20
  • Position: #108 / 234
  • Number of attempts: 8
Add semicolons - 10715 entries

Simply add a semicolon at the end of each line

  • Best score: 10
  • Best player score: 11
  • Position: #1731 / 3019
  • Number of attempts: 3
Bad Copy Syntax - 1951 entries

Copy should be from right to left, but sometimes you type it wrong.

  • Best score: 18
  • Best player score: 19
  • Position: #204 / 497
  • Number of attempts: 4
Split line with dots - 2113 entries

This line is too long, split it.

  • Best score: 15
  • Best player score: 15
  • Position: #160 / 625
  • Number of attempts: 3
remove lines containing the word "reader" - 3480 entries

easy stuff

  • Best score: 9
  • Best player score: 10
  • Position: #830 / 1127
  • Number of attempts: 3
Com(m)a Trouble - 3454 entries

Someone was real stupid when placing his commas. Can you fix it?

  • Best score: 12
  • Best player score: 13
  • Position: #312 / 775
  • Number of attempts: 7
Box it - 7718 entries

Create a box around a line.

  • Best score: 21
  • Best player score: 22
  • Position: #546 / 1841
  • Number of attempts: 4
Tables, Functions, Sprocs - 121 entries

In order to load some scripts into my database in the correct order I need to load tables first (t_), then functions (fn_), then stored procedures (sp_). The order of the t_ lines and the order of the sp_ lines should also match. Reorder the lines so they will load correctly.

  • Best score: 10
  • Best player score: 11
  • Position: #32 / 42
  • Number of attempts: 3
multiple cursor alternative - 1452 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: 20
  • Position: #192 / 371
  • Number of attempts: 8
From argument to object - 1439 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: 17
  • Position: #142 / 440
  • Number of attempts: 3
Every other line - 2850 entries

AaAaAaA

  • Best score: 12
  • Best player score: 13
  • Position: #262 / 690
  • Number of attempts: 6
Copy three lines - 2819 entries

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

  • Best score: 13
  • Best player score: 13
  • Position: #178 / 629
  • Number of attempts: 6
Extract argument from function - 2261 entries

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

  • Best score: 13
  • Best player score: 14
  • Position: #382 / 735
  • Number of attempts: 5
Search and Replace 0 - 4722 entries

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

  • Best score: 12
  • Best player score: 13
  • Position: #842 / 1562
  • Number of attempts: 5
That hyphen - 2517 entries

"vim vi improved"

  • Best score: 9
  • Best player score: 10
  • Position: #273 / 687
  • Number of attempts: 3
comment and uncomment code inline - 1019 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: #201 / 301
  • Number of attempts: 2
Just the middle - 11281 entries

Delete the instructions at the top and bottom.

  • Best score: 7
  • Best player score: 8
  • Position: #3155 / 4139
  • Number of attempts: 3
Team names - 1783 entries

The team names are misspelled.

  • Best score: 16
  • Best player score: 17
  • Position: #316 / 573
  • Number of attempts: 4
Turn a ninja to case-insensitive [Nn][Ii][Nn][Jj][Aa] regexp! - 53 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: 19
  • Position: #31 / 32
  • Number of attempts: 3
Basic renumbering - 5476 entries

Renumbering Basic.

  • Best score: 11
  • Best player score: 12
  • Position: #290 / 1237
  • Number of attempts: 10
Simple addition - 301 entries

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

  • Best score: 12
  • Best player score: 13
  • Position: #72 / 112
  • Number of attempts: 2
Combines all items - 290 entries

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

  • Best score: 9
  • Best player score: 10
  • Position: #121 / 131
  • Number of attempts: 2
Vice versa - 7598 entries

Little role switching.

  • Best score: 12
  • Best player score: 13
  • Position: #831 / 2059
  • Number of attempts: 4
Sort files from hosts - 167 entries

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

  • Best score: 15
  • Best player score: 16
  • Position: #28 / 70
  • Number of attempts: 3
Order and join - 900 entries

There's something special about the input order.

  • Best score: 10
  • Best player score: 11
  • Position: #131 / 246
  • Number of attempts: 5
Change attribute to getter - 121 entries

Wrap attributes with a getter method.

  • Best score: 24
  • Best player score: 25
  • Position: #38 / 51
  • Number of attempts: 8
Align commas - 1046 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: 12
  • Position: #100 / 238
  • Number of attempts: 10
One to Ten - 2116 entries

Generate the sequence of numbers from 1 to 10, one number per line. Inspired by this Reddit thread: https://redd.it/ak4it2

  • Best score: 12
  • Best player score: 12
  • Position: #338 / 647
  • Number of attempts: 3
Line under headers - 1933 entries

Put a line under each header, and remove the other markdown formatting.

  • Best score: 24
  • Best player score: 27
  • Position: #187 / 476
  • Number of attempts: 5
Increment each number - 957 entries

Increment each number individually by one

  • Best score: 15
  • Best player score: 21
  • Position: #174 / 236
  • Number of attempts: 1
citizen_hacks_2019_challenge6 - 53 entries

For the Citizen Hacks 2019 Vim competition.

  • Best score: 3
  • Best player score: 3
  • Position: #36 / 43
  • Number of attempts: 1
Join 'em - 234 entries

This shouldn't be too tough

  • Best score: 4
  • Best player score: 4
  • Position: #7 / 139
  • Number of attempts: 1
change parenthesis - 260 entries

change the pair of braces into a pair of parentheses

  • Best score: 9
  • Best player score: 10
  • Position: #133 / 147
  • Number of attempts: 1
Reorder the groups - 1119 entries

Change the order so that the groups of fruit come before the vegetables.

  • Best score: 14
  • Best player score: 15
  • Position: #118 / 254
  • Number of attempts: 6
Array transposition - 2321 entries

Transpose two arrays into one.

  • Best score: 16
  • Best player score: 17
  • Position: #165 / 434
  • Number of attempts: 8
Swap assigned value - 567 entries

Simple problem but looking for interesting solutions.

  • Best score: 10
  • Best player score: 11
  • Position: #180 / 237
  • Number of attempts: 6
Collect List - 4203 entries

Convert to comma separated list.

  • Best score: 12
  • Best player score: 12
  • Position: #513 / 1173
  • Number of attempts: 3
camel riding - 757 entries

add a prefix on some camelCase variables

  • Best score: 15
  • Best player score: 16
  • Position: #145 / 271
  • Number of attempts: 3
Space out the alphabet - 1602 entries

Put 3 spaces between adjacent letters.

  • Best score: 15
  • Best player score: 16
  • Position: #132 / 436
  • Number of attempts: 6
Line 'em up! - 373 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: 17
  • Position: #35 / 106
  • Number of attempts: 14
Condensed Cases - 764 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: #96 / 234
  • Number of attempts: 4
I forgot quotes - 15804 entries

Oops.

  • Best score: 10
  • Best player score: 11
  • Position: #1227 / 4123
  • Number of attempts: 9
Subtraction - 177 entries

Solve the equations.

  • Best score: 18
  • Best player score: 19
  • Position: #14 / 60
  • Number of attempts: 12
-a-b-c- - 3129 entries

Put hyphens everywhere.

  • Best score: 13
  • Best player score: 14
  • Position: #420 / 1116
  • Number of attempts: 4
Count both ways - 968 entries

Right AND down.

  • Best score: 13
  • Best player score: 14
  • Position: #85 / 344
  • Number of attempts: 3
Lisp Condense - 432 entries

Reduce 4 cons selection operations down to one function call.

  • Best score: 13
  • Best player score: 14
  • Position: #84 / 152
  • Number of attempts: 7
120 Degrees - 457 entries

Rotate that triangle.

  • Best score: 14
  • Best player score: 14
  • Position: #32 / 142
  • Number of attempts: 9
Gray area - 711 entries

It's a golf metaphor or something.

  • Best score: 11
  • Best player score: 12
  • Position: #121 / 263
  • Number of attempts: 4
Do you demand a shrubbery? - 1107 entries

Use :redir and crush the emacsgolfers.

  • Best score: 15
  • Best player score: 28
  • Position: #204 / 292
  • Number of attempts: 4
Don't know what this is - 1959 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: #233 / 574
  • Number of attempts: 3
Two become one - 706 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: 26
  • Position: #37 / 204
  • Number of attempts: 7
A HAPPY NEW YEAR 2014 ! - 10560 entries

A HAPPY NEW YEAR 2014 !

  • Best score: 11
  • Best player score: 12
  • Position: #2476 / 3645
  • Number of attempts: 2
Letter case trickery - 1563 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: 10
  • Position: #166 / 503
  • Number of attempts: 7
quotes inside quotes - 3065 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: 14
  • Position: #346 / 1054
  • Number of attempts: 3
Words in parens - 12775 entries

We should all ace this, right?

  • Best score: 13
  • Best player score: 14
  • Position: #1153 / 3926
  • Number of attempts: 4
Harder than "abcd > a b c d" - 75 entries

Not as easy as the last challenge. This time, just one space between a and b, up to 25 spaces between y and z. (Removed some lines; diff was too long.)

  • Best score: 15
  • Best player score: 16
  • Position: #12 / 38
  • Number of attempts: 4
Block Fun 1 - 187 entries

Manipulate the columns to produce desired result.

  • Best score: 14
  • Best player score: 15
  • Position: #17 / 71
  • Number of attempts: 13
Circle of Fifths with Sharps - 92 entries

Display a list of the Circle of Fifths with corresponding solfege syllables with sharps. Handling spaces may be tricky.

  • Best score: 24
  • Best player score: 25
  • Position: #15 / 34
  • Number of attempts: 7
NATO phonetic alphabet - 490 entries

Transform the series of words into a list.

  • Best score: 19
  • Best player score: 20
  • Position: #55 / 185
  • Number of attempts: 3
The name of the game - 636 entries

End up with the name of the game.

  • Best score: 11
  • Best player score: 12
  • Position: #313 / 348
  • Number of attempts: 2
SFD-ROC: vimvimvim - 1527 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: #240 / 429
  • Number of attempts: 8
Unwrap the text of an email message - 178 entries

Reverse of "Wrap the text of an email message to 79 characters". gq and gw are great for wrapping paragraphs. But sometimes other programs choke on your wrapped lines. What's the best way to un-gq?

  • Best score: 16
  • Best player score: 17
  • Position: #35 / 70
  • Number of attempts: 3
Saving the hashes(#) - 1973 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: 21
  • Position: #124 / 468
  • Number of attempts: 8
Let's play some Ivmgolf - 1036 entries

Oops, I spelled that wrong.

  • Best score: 7
  • Best player score: 9
  • Position: #318 / 425
  • Number of attempts: 4
Vertical Limit - 2386 entries

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

  • Best score: 21
  • Best player score: 22
  • Position: #173 / 723
  • Number of attempts: 5
Exchanging Quotes - 800 entries

Sometimes you need to exchange a choice of quotes in some code.

  • Best score: 30
  • Best player score: 31
  • Position: #39 / 220
  • Number of attempts: 7
replacing each line of a block selection - 2862 entries

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

  • Best score: 18
  • Best player score: 19
  • Position: #217 / 749
  • Number of attempts: 7
Switch function arguments - 1996 entries

How to switch two arguments of a function.

  • Best score: 11
  • Best player score: 12
  • Position: #314 / 632
  • Number of attempts: 2
Append semicolon after expressions - 973 entries

Some lines need the semicolon, some don't.

  • Best score: 11
  • Best player score: 12
  • Position: #244 / 393
  • Number of attempts: 1
switch variable - 4974 entries

how fast can you switch two variable ?

  • Best score: 11
  • Best player score: 12
  • Position: #987 / 1715
  • Number of attempts: 2
The meaning - 526 entries

Numbers are fun!

  • Best score: 5
  • Best player score: 5
  • Position: #298 / 340
  • Number of attempts: 1
Make it more readable - 1921 entries

Insert blank lines to make it more organized and readable

  • Best score: 13
  • Best player score: 14
  • Position: #191 / 631
  • Number of attempts: 4
Line Zipper - 448 entries

Zip/pair related lines.

  • Best score: 12
  • Best player score: 13
  • Position: #62 / 208
  • Number of attempts: 6
remove dupes from array - 1324 entries

given a random string that contains a ruby-esque array, make sure that there are no duplicate elements

  • Best score: 17
  • Best player score: 18
  • Position: #103 / 328
  • Number of attempts: 6
imports alignment (python) - 656 entries

Align as one import per line.

  • Best score: 17
  • Best player score: 18
  • Position: #53 / 193
  • Number of attempts: 13
Numbering a List - 1838 entries

Pretty simple, number the list.

  • Best score: 13
  • Best player score: 17
  • Position: #102 / 631
  • Number of attempts: 5
Ruby 1.9 hashes - 1177 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: 13
  • Position: #178 / 387
  • Number of attempts: 4
Shebangs for all - 1788 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: 12
  • Position: #150 / 471
  • Number of attempts: 5
A Simple One - 968 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: #520 / 629
  • Number of attempts: 1
The Cake is a Lie - 1238 entries

Correct the capitalization of each word

  • Best score: 9
  • Best player score: 10
  • Position: #374 / 497
  • Number of attempts: 4
Compile C - 341 entries

You might have to get clever to do this one.

  • Best score: 19
  • Best player score: 20
  • Position: #23 / 126
  • Number of attempts: 12
Reformat a C golf submission - 536 entries

Take this C golf submission (for the "tiny but standards-compliant Hello World program" category, naturally), and turn it into formatted C code.

  • Best score: 22
  • Best player score: 35
  • Position: #133 / 195
  • Number of attempts: 2
Get rid of html tags - 348 entries

Want to read more about Vim's background? Then get rid of those html tags...

  • Best score: 15
  • Best player score: 16
  • Position: #10 / 209
  • Number of attempts: 2
Change the content of a string - 1393 entries

This docstring is a complete lie. Fix it.

  • Best score: 22
  • Best player score: 23
  • Position: #277 / 531
  • Number of attempts: 3
Sort and add attributes - 1226 entries

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

  • Best score: 33
  • Best player score: 34
  • Position: #331 / 495
  • Number of attempts: 2
Reconstruct the Sentence - 1195 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: #207 / 352
  • Number of attempts: 5
Simple text editing with Vim - 11746 entries

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

  • Best score: 13
  • Best player score: 14
  • Position: #1846 / 3444
  • Number of attempts: 4
Reformat/Refactor a Golfer Class - 6130 entries

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

  • Best score: 32
  • Best player score: 33
  • Position: #262 / 1512
  • Number of attempts: 7

Contributed Challenges

Fill in the chess board - 665 entries

Fill in the name of each square using its file (a-h) and rank (1-8).

Michel Viktor
Twitter:

entered into 111 challenges

contributed 1 challenges