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 - 1350 entries

Quick and easy

  • Best score: 7
  • Best player score: 8
  • Position: #93 / 440
  • Number of attempts: 1
delete swap - 1650 entries

delete all swap

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

Simple number generation

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

Simple challenge for frequent action while programming.

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

Modernise and clean up some C++ code.

  • Best score: 34
  • Best player score: 35
  • Position: #85 / 316
  • Number of attempts: 3
swap number pairs - 2023 entries

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

  • Best score: 16
  • Best player score: 17
  • Position: #94 / 373
  • Number of attempts: 4
Python: Def to Lambda - 441 entries

LAMBDA!!!

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

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

  • Best score: 9
  • Best player score: 10
  • Position: #427 / 1086
  • Number of attempts: 3
Satisfy the go linter - 2360 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: #188 / 465
  • Number of attempts: 7
Add quotes to ansible playbook - 946 entries

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

  • Best score: 8
  • Best player score: 9
  • Position: #164 / 302
  • Number of attempts: 4
Multiline to Single Line - 680 entries

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

  • Best score: 5
  • Best player score: 5
  • Position: #149 / 298
  • Number of attempts: 1
xrandr outputs and dashes - 671 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 / 218
  • Number of attempts: 4
From a Thunderlink to a Markdown link - 757 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 / 168
  • Number of attempts: 9
Yo To Hello - 1127 entries

Simply Turn Yo To Hello

  • Best score: 10
  • Best player score: 10
  • Position: #329 / 522
  • Number of attempts: 4
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: 23
  • Position: #2800 / 7384
  • Number of attempts: 6
Swap values - 4554 entries

Well, swap the values...

  • Best score: 11
  • Best player score: 12
  • Position: #519 / 1259
  • Number of attempts: 5
prepend * to every non-blank line - 6254 entries

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

  • Best score: 10
  • Best player score: 11
  • Position: #730 / 1530
  • Number of attempts: 3
One number per line - 18673 entries

Just give me the numbers.

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

pi square vim

  • Best score: 20
  • Best player score: 21
  • Position: #51 / 133
  • Number of attempts: 7
Swap values inside brackets - 2477 entries

Easy challenge.

  • Best score: 14
  • Best player score: 15
  • Position: #211 / 573
  • Number of attempts: 10
Unsemantic linewrapping - 901 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: #149 / 226
  • Number of attempts: 2
V to the i - 4771 entries

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

  • Best score: 7
  • Best player score: 8
  • Position: #1477 / 1887
  • Number of attempts: 2
Applying same text modification in several lines - 2851 entries

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

  • Best score: 12
  • Best player score: 13
  • Position: #261 / 843
  • Number of attempts: 2
SCREAMING_SNAKE_CASE to Title Case - 1203 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: #114 / 247
  • Number of attempts: 8
Add semicolons - 10831 entries

Simply add a semicolon at the end of each line

  • Best score: 10
  • Best player score: 11
  • Position: #1742 / 3055
  • Number of attempts: 3
Bad Copy Syntax - 2009 entries

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

  • Best score: 18
  • Best player score: 19
  • Position: #209 / 518
  • Number of attempts: 4
Split line with dots - 2131 entries

This line is too long, split it.

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

easy stuff

  • Best score: 9
  • Best player score: 10
  • Position: #841 / 1151
  • Number of attempts: 3
Com(m)a Trouble - 3711 entries

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

  • Best score: 12
  • Best player score: 13
  • Position: #329 / 839
  • Number of attempts: 7
Box it - 7849 entries

Create a box around a line.

  • Best score: 21
  • Best player score: 22
  • Position: #551 / 1870
  • Number of attempts: 4
Tables, Functions, Sprocs - 129 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: #34 / 46
  • Number of attempts: 3
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: 20
  • Position: #195 / 378
  • Number of attempts: 8
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: 17
  • Position: #142 / 453
  • Number of attempts: 3
Every other line - 2902 entries

AaAaAaA

  • Best score: 12
  • Best player score: 13
  • Position: #265 / 702
  • Number of attempts: 6
Copy three lines - 2869 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 / 639
  • Number of attempts: 6
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: 14
  • Position: #387 / 750
  • Number of attempts: 5
Search and Replace 0 - 4851 entries

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

  • Best score: 12
  • Best player score: 13
  • Position: #866 / 1604
  • Number of attempts: 5
That hyphen - 2572 entries

"vim vi improved"

  • Best score: 9
  • Best player score: 10
  • Position: #277 / 698
  • Number of attempts: 3
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: #209 / 316
  • Number of attempts: 2
Just the middle - 11380 entries

Delete the instructions at the top and bottom.

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

The team names are misspelled.

  • Best score: 16
  • Best player score: 17
  • Position: #321 / 585
  • Number of attempts: 4
Turn a ninja to case-insensitive [Nn][Ii][Nn][Jj][Aa] regexp! - 64 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: #36 / 38
  • Number of attempts: 3
Basic renumbering - 5605 entries

Renumbering Basic.

  • Best score: 11
  • Best player score: 12
  • Position: #300 / 1260
  • Number of attempts: 10
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: 13
  • Position: #75 / 118
  • 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: #125 / 139
  • Number of attempts: 2
Vice versa - 7865 entries

Little role switching.

  • Best score: 12
  • Best player score: 13
  • Position: #848 / 2114
  • Number of attempts: 4
Sort files from hosts - 180 entries

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

  • Best score: 15
  • Best player score: 16
  • Position: #30 / 75
  • Number of attempts: 3
Order and join - 965 entries

There's something special about the input order.

  • Best score: 10
  • Best player score: 11
  • Position: #137 / 258
  • Number of attempts: 5
Change attribute to getter - 134 entries

Wrap attributes with a getter method.

  • Best score: 24
  • Best player score: 25
  • Position: #43 / 58
  • Number of attempts: 8
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: 12
  • Position: #105 / 243
  • Number of attempts: 10
One to Ten - 2174 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 / 664
  • Number of attempts: 3
Line under headers - 2023 entries

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

  • Best score: 24
  • Best player score: 27
  • Position: #196 / 498
  • Number of attempts: 5
Increment each number - 995 entries

Increment each number individually by one

  • Best score: 15
  • Best player score: 21
  • Position: #179 / 245
  • Number of attempts: 1
citizen_hacks_2019_challenge6 - 61 entries

For the Citizen Hacks 2019 Vim competition.

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

This shouldn't be too tough

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

change the pair of braces into a pair of parentheses

  • Best score: 9
  • Best player score: 10
  • Position: #140 / 160
  • Number of attempts: 1
Reorder the groups - 1146 entries

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

  • Best score: 14
  • Best player score: 15
  • Position: #121 / 262
  • Number of attempts: 6
Array transposition - 2407 entries

Transpose two arrays into one.

  • Best score: 16
  • Best player score: 17
  • Position: #170 / 445
  • Number of attempts: 8
Swap assigned value - 628 entries

Simple problem but looking for interesting solutions.

  • Best score: 10
  • Best player score: 11
  • Position: #189 / 252
  • Number of attempts: 6
Collect List - 4267 entries

Convert to comma separated list.

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

add a prefix on some camelCase variables

  • Best score: 15
  • Best player score: 16
  • Position: #148 / 277
  • Number of attempts: 3
Space out the alphabet - 1630 entries

Put 3 spaces between adjacent letters.

  • Best score: 15
  • Best player score: 16
  • Position: #134 / 442
  • Number of attempts: 6
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: 17
  • Position: #35 / 112
  • Number of attempts: 14
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: #98 / 244
  • Number of attempts: 4
I forgot quotes - 15946 entries

Oops.

  • Best score: 10
  • Best player score: 11
  • Position: #1235 / 4166
  • Number of attempts: 9
Subtraction - 179 entries

Solve the equations.

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

Put hyphens everywhere.

  • Best score: 13
  • Best player score: 14
  • Position: #423 / 1132
  • Number of attempts: 4
Count both ways - 1006 entries

Right AND down.

  • Best score: 13
  • Best player score: 14
  • Position: #87 / 352
  • Number of attempts: 3
Lisp Condense - 449 entries

Reduce 4 cons selection operations down to one function call.

  • Best score: 13
  • Best player score: 14
  • Position: #86 / 157
  • Number of attempts: 7
120 Degrees - 469 entries

Rotate that triangle.

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

It's a golf metaphor or something.

  • Best score: 11
  • Best player score: 12
  • Position: #122 / 270
  • Number of attempts: 4
Do you demand a shrubbery? - 1136 entries

Use :redir and crush the emacsgolfers.

  • Best score: 15
  • Best player score: 28
  • Position: #207 / 298
  • Number of attempts: 4
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: #237 / 581
  • Number of attempts: 3
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: 26
  • Position: #38 / 208
  • Number of attempts: 7
A HAPPY NEW YEAR 2014 ! - 10652 entries

A HAPPY NEW YEAR 2014 !

  • Best score: 11
  • Best player score: 12
  • Position: #2495 / 3677
  • Number of attempts: 2
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: 10
  • Position: #169 / 514
  • Number of attempts: 7
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: 14
  • Position: #346 / 1073
  • Number of attempts: 3
Words in parens - 12868 entries

We should all ace this, right?

  • Best score: 13
  • Best player score: 14
  • Position: #1157 / 3950
  • Number of attempts: 4
Harder than "abcd > a b c d" - 78 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: #13 / 41
  • Number of attempts: 4
Block Fun 1 - 190 entries

Manipulate the columns to produce desired result.

  • Best score: 14
  • Best player score: 15
  • Position: #18 / 74
  • Number of attempts: 13
Circle of Fifths with Sharps - 97 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: #16 / 37
  • Number of attempts: 7
NATO phonetic alphabet - 506 entries

Transform the series of words into a list.

  • Best score: 19
  • Best player score: 20
  • Position: #56 / 194
  • Number of attempts: 3
The name of the game - 654 entries

End up with the name of the game.

  • Best score: 11
  • Best player score: 12
  • Position: #322 / 359
  • Number of attempts: 2
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: #245 / 443
  • Number of attempts: 8
Unwrap the text of an email message - 188 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: #36 / 73
  • Number of attempts: 3
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: 21
  • Position: #125 / 476
  • Number of attempts: 8
Let's play some Ivmgolf - 1096 entries

Oops, I spelled that wrong.

  • Best score: 7
  • Best player score: 9
  • Position: #325 / 442
  • Number of attempts: 4
Vertical Limit - 2487 entries

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

  • Best score: 21
  • Best player score: 22
  • Position: #177 / 748
  • Number of attempts: 5
Exchanging Quotes - 824 entries

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

  • Best score: 30
  • Best player score: 31
  • Position: #42 / 227
  • 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: 19
  • Position: #220 / 772
  • Number of attempts: 7
Switch function arguments - 2085 entries

How to switch two arguments of a function.

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

Some lines need the semicolon, some don't.

  • Best score: 11
  • Best player score: 12
  • Position: #252 / 410
  • Number of attempts: 1
switch variable - 5045 entries

how fast can you switch two variable ?

  • Best score: 11
  • Best player score: 12
  • Position: #997 / 1742
  • Number of attempts: 2
The meaning - 566 entries

Numbers are fun!

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

Insert blank lines to make it more organized and readable

  • Best score: 13
  • Best player score: 14
  • Position: #194 / 643
  • Number of attempts: 4
Line Zipper - 454 entries

Zip/pair related lines.

  • Best score: 12
  • Best player score: 13
  • Position: #63 / 212
  • Number of attempts: 6
remove dupes from array - 1345 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: #105 / 333
  • Number of attempts: 6
imports alignment (python) - 663 entries

Align as one import per line.

  • Best score: 17
  • Best player score: 18
  • Position: #54 / 196
  • Number of attempts: 13
Numbering a List - 1869 entries

Pretty simple, number the list.

  • Best score: 13
  • Best player score: 17
  • Position: #110 / 646
  • Number of attempts: 5
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: 13
  • Position: #182 / 402
  • Number of attempts: 4
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: 12
  • Position: #154 / 502
  • Number of attempts: 5
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: #520 / 648
  • Number of attempts: 1
The Cake is a Lie - 1301 entries

Correct the capitalization of each word

  • Best score: 9
  • Best player score: 10
  • Position: #382 / 517
  • Number of attempts: 4
Compile C - 366 entries

You might have to get clever to do this one.

  • Best score: 19
  • Best player score: 20
  • Position: #27 / 133
  • Number of attempts: 12
Reformat a C golf submission - 574 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: #139 / 203
  • Number of attempts: 2
Get rid of html tags - 378 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 / 222
  • Number of attempts: 2
Change the content of a string - 1502 entries

This docstring is a complete lie. Fix it.

  • Best score: 22
  • Best player score: 23
  • Position: #295 / 567
  • Number of attempts: 3
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: #359 / 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: #230 / 397
  • Number of attempts: 5
Simple text editing with Vim - 12491 entries

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

  • Best score: 13
  • Best player score: 14
  • Position: #1882 / 3626
  • 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: 33
  • Position: #266 / 1652
  • Number of attempts: 7

Contributed Challenges

Fill in the chess board - 933 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