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

hello-world-vimgolf - 303 entries

Simple number generation

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

Simple challenge for frequent action while programming.

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

Modernise and clean up some C++ code.

  • Best score: 34
  • Best player score: 35
  • Position: #54 / 152
  • Number of attempts: 3
swap number pairs - 1293 entries

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

  • Best score: 16
  • Best player score: 17
  • Position: #74 / 244
  • Number of attempts: 4
Python: Def to Lambda - 221 entries

LAMBDA!!!

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

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

  • Best score: 9
  • Best player score: 10
  • Position: #390 / 938
  • Number of attempts: 3
Satisfy the go linter - 1625 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: #134 / 334
  • Number of attempts: 7
Add quotes to ansible playbook - 597 entries

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

  • Best score: 8
  • Best player score: 9
  • Position: #123 / 190
  • Number of attempts: 4
Multiline to Single Line - 378 entries

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

  • Best score: 5
  • Best player score: 5
  • Position: #149 / 179
  • Number of attempts: 1
xrandr outputs and dashes - 568 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 / 184
  • Number of attempts: 4
From a Thunderlink to a Markdown link - 655 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 / 145
  • Number of attempts: 9
Yo To Hello - 983 entries

Simply Turn Yo To Hello

  • Best score: 10
  • Best player score: 10
  • Position: #329 / 454
  • Number of attempts: 4
Simple, Practical, and Common - 32778 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: #2747 / 7242
  • Number of attempts: 6
Swap values - 4409 entries

Well, swap the values...

  • Best score: 11
  • Best player score: 12
  • Position: #509 / 1235
  • Number of attempts: 5
prepend * to every non-blank line - 5829 entries

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

  • Best score: 10
  • Best player score: 11
  • Position: #692 / 1434
  • Number of attempts: 3
One number per line - 18295 entries

Just give me the numbers.

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

pi square vim

  • Best score: 20
  • Best player score: 21
  • Position: #47 / 127
  • Number of attempts: 7
Swap values inside brackets - 2417 entries

Easy challenge.

  • Best score: 14
  • Best player score: 15
  • Position: #205 / 557
  • Number of attempts: 10
Unsemantic linewrapping - 821 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: #138 / 205
  • Number of attempts: 2
V to the i - 4617 entries

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

  • Best score: 7
  • Best player score: 8
  • Position: #1457 / 1847
  • Number of attempts: 2
Applying same text modification in several lines - 2713 entries

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

  • Best score: 12
  • Best player score: 13
  • Position: #244 / 807
  • Number of attempts: 2
SCREAMING_SNAKE_CASE to Title Case - 1089 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: #105 / 227
  • Number of attempts: 8
Add semicolons - 10467 entries

Simply add a semicolon at the end of each line

  • Best score: 10
  • Best player score: 11
  • Position: #1708 / 2966
  • Number of attempts: 3
Bad Copy Syntax - 1904 entries

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

  • Best score: 18
  • Best player score: 19
  • Position: #200 / 485
  • Number of attempts: 4
Split line with dots - 2085 entries

This line is too long, split it.

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

easy stuff

  • Best score: 9
  • Best player score: 10
  • Position: #820 / 1113
  • Number of attempts: 3
Com(m)a Trouble - 3308 entries

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

  • Best score: 12
  • Best player score: 13
  • Position: #300 / 746
  • Number of attempts: 7
Box it - 7661 entries

Create a box around a line.

  • Best score: 21
  • Best player score: 22
  • Position: #538 / 1830
  • Number of attempts: 4
Tables, Functions, Sprocs - 109 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: #30 / 37
  • Number of attempts: 3
multiple cursor alternative - 1441 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: #190 / 368
  • Number of attempts: 8
From argument to object - 1258 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 / 416
  • Number of attempts: 3
Every other line - 2790 entries

AaAaAaA

  • Best score: 12
  • Best player score: 13
  • Position: #258 / 679
  • Number of attempts: 6
Copy three lines - 2767 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 / 620
  • Number of attempts: 6
Extract argument from function - 2195 entries

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

  • Best score: 13
  • Best player score: 14
  • Position: #372 / 724
  • Number of attempts: 5
Search and Replace 0 - 4591 entries

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

  • Best score: 12
  • Best player score: 13
  • Position: #815 / 1521
  • Number of attempts: 5
That hyphen - 2472 entries

"vim vi improved"

  • Best score: 9
  • Best player score: 10
  • Position: #270 / 676
  • Number of attempts: 3
comment and uncomment code inline - 978 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: #196 / 292
  • Number of attempts: 2
Just the middle - 11086 entries

Delete the instructions at the top and bottom.

  • Best score: 7
  • Best player score: 8
  • Position: #3132 / 4093
  • Number of attempts: 3
Team names - 1766 entries

The team names are misspelled.

  • Best score: 16
  • Best player score: 17
  • Position: #313 / 566
  • Number of attempts: 4
Turn a ninja to case-insensitive [Nn][Ii][Nn][Jj][Aa] regexp! - 46 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: #27 / 28
  • Number of attempts: 3
Basic renumbering - 5408 entries

Renumbering Basic.

  • Best score: 11
  • Best player score: 12
  • Position: #279 / 1221
  • Number of attempts: 10
Combines all items - 265 entries

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

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

Little role switching.

  • Best score: 12
  • Best player score: 13
  • Position: #818 / 2023
  • Number of attempts: 4
Change attribute to getter - 106 entries

Wrap attributes with a getter method.

  • Best score: 24
  • Best player score: 25
  • Position: #36 / 45
  • Number of attempts: 8
Align commas - 1021 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: #97 / 233
  • Number of attempts: 10
One to Ten - 2072 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 / 635
  • Number of attempts: 3
Line under headers - 1890 entries

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

  • Best score: 24
  • Best player score: 27
  • Position: #183 / 466
  • Number of attempts: 5
Increment each number - 946 entries

Increment each number individually by one

  • Best score: 15
  • Best player score: 21
  • Position: #172 / 233
  • Number of attempts: 1
citizen_hacks_2019_challenge6 - 44 entries

For the Citizen Hacks 2019 Vim competition.

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

This shouldn't be too tough

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

change the pair of braces into a pair of parentheses

  • Best score: 9
  • Best player score: 10
  • Position: #126 / 135
  • Number of attempts: 1
Reorder the groups - 1095 entries

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

  • Best score: 14
  • Best player score: 15
  • Position: #113 / 249
  • Number of attempts: 6
Array transposition - 2271 entries

Transpose two arrays into one.

  • Best score: 16
  • Best player score: 17
  • Position: #162 / 427
  • Number of attempts: 8
Swap assigned value - 540 entries

Simple problem but looking for interesting solutions.

  • Best score: 10
  • Best player score: 11
  • Position: #176 / 230
  • Number of attempts: 6
Collect List - 4155 entries

Convert to comma separated list.

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

add a prefix on some camelCase variables

  • Best score: 15
  • Best player score: 16
  • Position: #143 / 264
  • Number of attempts: 3
Space out the alphabet - 1563 entries

Put 3 spaces between adjacent letters.

  • Best score: 15
  • Best player score: 16
  • Position: #130 / 427
  • Number of attempts: 6
Line 'em up! - 361 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 / 103
  • Number of attempts: 14
Condensed Cases - 735 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 / 226
  • Number of attempts: 4
I forgot quotes - 15668 entries

Oops.

  • Best score: 10
  • Best player score: 11
  • Position: #1218 / 4099
  • Number of attempts: 9
Subtraction - 167 entries

Solve the equations.

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

Put hyphens everywhere.

  • Best score: 13
  • Best player score: 14
  • Position: #415 / 1101
  • Number of attempts: 4
Count both ways - 935 entries

Right AND down.

  • Best score: 13
  • Best player score: 14
  • Position: #82 / 334
  • Number of attempts: 3
Lisp Condense - 421 entries

Reduce 4 cons selection operations down to one function call.

  • Best score: 13
  • Best player score: 14
  • Position: #82 / 148
  • Number of attempts: 7
120 Degrees - 416 entries

Rotate that triangle.

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

It's a golf metaphor or something.

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

Use :redir and crush the emacsgolfers.

  • Best score: 15
  • Best player score: 28
  • Position: #201 / 288
  • Number of attempts: 4
Don't know what this is - 1927 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: #229 / 566
  • Number of attempts: 3
Two become one - 699 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 / 201
  • Number of attempts: 7
A HAPPY NEW YEAR 2014 ! - 10515 entries

A HAPPY NEW YEAR 2014 !

  • Best score: 11
  • Best player score: 12
  • Position: #2465 / 3630
  • Number of attempts: 2
Letter case trickery - 1530 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: #162 / 495
  • Number of attempts: 7
quotes inside quotes - 3003 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 / 1038
  • Number of attempts: 3
Words in parens - 12690 entries

We should all ace this, right?

  • Best score: 13
  • Best player score: 14
  • Position: #1146 / 3906
  • 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 - 174 entries

Manipulate the columns to produce desired result.

  • Best score: 14
  • Best player score: 15
  • Position: #16 / 68
  • Number of attempts: 13
Circle of Fifths with Sharps - 82 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: #14 / 33
  • Number of attempts: 7
NATO phonetic alphabet - 459 entries

Transform the series of words into a list.

  • Best score: 19
  • Best player score: 20
  • Position: #50 / 173
  • Number of attempts: 3
The name of the game - 614 entries

End up with the name of the game.

  • Best score: 11
  • Best player score: 12
  • Position: #300 / 334
  • Number of attempts: 2
SFD-ROC: vimvimvim - 1460 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: #232 / 414
  • Number of attempts: 8
Unwrap the text of an email message - 157 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: #31 / 64
  • Number of attempts: 3
Saving the hashes(#) - 1940 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: #121 / 463
  • Number of attempts: 8
Let's play some Ivmgolf - 988 entries

Oops, I spelled that wrong.

  • Best score: 7
  • Best player score: 9
  • Position: #310 / 410
  • Number of attempts: 4
Vertical Limit - 2333 entries

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

  • Best score: 21
  • Best player score: 22
  • Position: #168 / 708
  • Number of attempts: 5
Exchanging Quotes - 788 entries

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

  • Best score: 30
  • Best player score: 31
  • Position: #38 / 217
  • Number of attempts: 7
replacing each line of a block selection - 2768 entries

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

  • Best score: 18
  • Best player score: 19
  • Position: #212 / 729
  • Number of attempts: 7
Switch function arguments - 1955 entries

How to switch two arguments of a function.

  • Best score: 11
  • Best player score: 12
  • Position: #309 / 620
  • Number of attempts: 2
Append semicolon after expressions - 931 entries

Some lines need the semicolon, some don't.

  • Best score: 11
  • Best player score: 12
  • Position: #238 / 378
  • Number of attempts: 1
switch variable - 4881 entries

how fast can you switch two variable ?

  • Best score: 11
  • Best player score: 12
  • Position: #973 / 1694
  • Number of attempts: 2
The meaning - 518 entries

Numbers are fun!

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

Insert blank lines to make it more organized and readable

  • Best score: 13
  • Best player score: 14
  • Position: #187 / 615
  • Number of attempts: 4
Line Zipper - 413 entries

Zip/pair related lines.

  • Best score: 12
  • Best player score: 13
  • Position: #57 / 199
  • Number of attempts: 6
remove dupes from array - 1266 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: #97 / 322
  • Number of attempts: 6
imports alignment (python) - 603 entries

Align as one import per line.

  • Best score: 17
  • Best player score: 18
  • Position: #51 / 183
  • Number of attempts: 13
Numbering a List - 1798 entries

Pretty simple, number the list.

  • Best score: 13
  • Best player score: 17
  • Position: #86 / 615
  • Number of attempts: 5
Ruby 1.9 hashes - 1128 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: #172 / 375
  • Number of attempts: 4
Shebangs for all - 1749 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: #144 / 462
  • Number of attempts: 5
A Simple One - 881 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 / 590
  • Number of attempts: 1
The Cake is a Lie - 1178 entries

Correct the capitalization of each word

  • Best score: 9
  • Best player score: 10
  • Position: #361 / 481
  • Number of attempts: 4
Compile C - 300 entries

You might have to get clever to do this one.

  • Best score: 19
  • Best player score: 20
  • Position: #20 / 116
  • Number of attempts: 12
Reformat a C golf submission - 507 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: #128 / 188
  • Number of attempts: 2
Get rid of html tags - 326 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 / 200
  • Number of attempts: 2
Change the content of a string - 1297 entries

This docstring is a complete lie. Fix it.

  • Best score: 22
  • Best player score: 23
  • Position: #262 / 502
  • Number of attempts: 3
Sort and add attributes - 1138 entries

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

  • Best score: 33
  • Best player score: 34
  • Position: #311 / 466
  • Number of attempts: 2
Reconstruct the Sentence - 1077 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: #199 / 333
  • Number of attempts: 5
Simple text editing with Vim - 11446 entries

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

  • Best score: 13
  • Best player score: 14
  • Position: #1824 / 3361
  • Number of attempts: 4
Reformat/Refactor a Golfer Class - 5869 entries

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

  • Best score: 32
  • Best player score: 33
  • Position: #259 / 1451
  • Number of attempts: 7

Contributed Challenges

Fill in the chess board - 237 entries

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

Michel Viktor
Twitter:

entered into 106 challenges

contributed 1 challenges