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

Remove adjacent duplicates - 445 entries

Try to find a way to remove adjacent duplicate letters.

  • Best score: 19
  • Best player score: 25
  • Position: #61 / 117
  • Number of attempts: 1
Lowercase first characters - 487 entries

This is the (abridged) input for Day 3 in Advent of Code 2019. The output is a format more suitable for Prolog programming: the two lines of input become two lists of pairs, joined together in a wires functor.

  • Best score: 33
  • Best player score: 41
  • Position: #97 / 183
  • Number of attempts: 3
Simple, Practical, and Common - 33617 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: #928 / 7421
  • Number of attempts: 2
prepend * to every non-blank line - 6312 entries

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

  • Best score: 10
  • Best player score: 12
  • Position: #772 / 1537
  • Number of attempts: 3
One number per line - 18727 entries

Just give me the numbers.

  • Best score: 14
  • Best player score: 22
  • Position: #2774 / 3864
  • Number of attempts: 1
Aliases for cd - 879 entries

Create these beautiful aliases with as few strokes as possible. Are you up for the challenge?

  • Best score: 30
  • Best player score: 45
  • Position: #73 / 155
  • Number of attempts: 1
vim = 22 / 7 - 475 entries

pi square vim

  • Best score: 20
  • Best player score: 20
  • Position: #2 / 135
  • Number of attempts: 4
V to the i - 4802 entries

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

  • Best score: 7
  • Best player score: 8
  • Position: #865 / 1893
  • Number of attempts: 2
Add semicolons - 10852 entries

Simply add a semicolon at the end of each line

  • Best score: 10
  • Best player score: 12
  • Position: #1866 / 3063
  • Number of attempts: 1
remove lines containing the word "reader" - 3586 entries

easy stuff

  • Best score: 9
  • Best player score: 10
  • Position: #577 / 1162
  • Number of attempts: 2
Box it - 7905 entries

Create a box around a line.

  • Best score: 21
  • Best player score: 22
  • Position: #527 / 1876
  • Number of attempts: 3
From argument to object - 1508 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: 18
  • Position: #174 / 458
  • Number of attempts: 1
Search and Replace 0 - 4989 entries

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

  • Best score: 12
  • Best player score: 12
  • Position: #171 / 1624
  • Number of attempts: 3
Across-Down Flip - 68 entries

Do this instead of the Sunday crossword.

  • Best score: 23
  • Best player score: 28
  • Position: #13 / 26
  • Number of attempts: 3
comment and uncomment code inline - 1122 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: #165 / 322
  • Number of attempts: 1
Stairstep digits - 394 entries

Remove the evens. Double the odds.

  • Best score: 9
  • Best player score: 13
  • Position: #86 / 145
  • Number of attempts: 1
Nesting SASS - 266 entries

Move a block inside another block and indent it

  • Best score: 9
  • Best player score: 11
  • Position: #48 / 96
  • Number of attempts: 2
Scrambled numbers - 807 entries

Four is NOT 1. One is 1.

  • Best score: 18
  • Best player score: 24
  • Position: #110 / 184
  • Number of attempts: 2
Sierpinski's Triangle - 86 entries

Build the famous fractal, Sierpinski's Triangle.

  • Best score: 25
  • Best player score: 25
  • Position: #2 / 27
  • Number of attempts: 4
Swap assigned value - 647 entries

Simple problem but looking for interesting solutions.

  • Best score: 10
  • Best player score: 10
  • Position: #12 / 254
  • Number of attempts: 4
Cartesian product - 255 entries

{1,2,3,4,5} X {1,2,3,4,5}

  • Best score: 24
  • Best player score: 26
  • Position: #24 / 95
  • Number of attempts: 4
Change your calendar - 392 entries

Happy New Year!

  • Best score: 18
  • Best player score: 19
  • Position: #15 / 87
  • Number of attempts: 3
I forgot quotes - 15983 entries

Oops.

  • Best score: 10
  • Best player score: 10
  • Position: #132 / 4180
  • Number of attempts: 2
Lisp Condense - 460 entries

Reduce 4 cons selection operations down to one function call.

  • Best score: 13
  • Best player score: 13
  • Position: #26 / 158
  • Number of attempts: 4
A HAPPY NEW YEAR 2014 ! - 10663 entries

A HAPPY NEW YEAR 2014 !

  • Best score: 11
  • Best player score: 12
  • Position: #1739 / 3683
  • Number of attempts: 1
Letter case trickery - 1630 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: #326 / 518
  • Number of attempts: 1
quotes inside quotes - 3159 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: 17
  • Position: #802 / 1078
  • Number of attempts: 1
Change The Perspective - 38 entries

This is a go game recodes file(.sgf file, refer to http://www.red-bean.com/sgf/). It base on such a coordinate system: in vertical direction, is from top(farthest end) to bottom, mark as a,b,c,...,s(19*19 board); in horizontal direction, is from left to right, uses the same notations. For Example, the coordinate notation 'cq', is the position at the bottom-left corner(vertical coordinate first). The record is from one player's perspective. We need to change to another's, but we don't want to change coordinate system, let it keep top to bottom and left to right. so we have to change the coordinates, a <-> s, b <-> r,c <-> q, etc. the Position 'cq', as transformation, it will be 'qd'.

  • Best score: 33
  • Best player score: 54
  • Position: #23 / 23
  • Number of attempts: 1
Number an outline - 280 entries

The indent and words are right, but the numbers are all wrong.

  • Best score: 25
  • Best player score: 51
  • Position: #39 / 78
  • Number of attempts: 2
Words in parens - 12935 entries

We should all ace this, right?

  • Best score: 13
  • Best player score: 15
  • Position: #1189 / 3963
  • Number of attempts: 3
Hole-in-one - 1018 entries

Lets take this golf thing literally.. Drive off the tee into the hole, and of course you don't strike the ball completely clean.

  • Best score: 15
  • Best player score: 19
  • Position: #174 / 304
  • Number of attempts: 2
Lookahead and Lookbehind - 70 entries

Look everywhere

  • Best score: 16
  • Best player score: 22
  • Position: #19 / 31
  • Number of attempts: 2
Minimalist Limerick - 520 entries

Reproduce this lovely poem.

  • Best score: 30
  • Best player score: 31
  • Position: #6 / 174
  • Number of attempts: 2
Coordinates placeholder - 73 entries

Place coordinates instead of target search.

  • Best score: 22
  • Best player score: 23
  • Position: #12 / 38
  • Number of attempts: 1
Define to require - 127 entries

When JSHint is enabled, there's a rule that doesn't let you have more than 6 arguments in a function, so the moment you need to add a 7th argument, you need to do a refactoring.

  • Best score: 62
  • Best player score: 62
  • Position: #2 / 50
  • Number of attempts: 4
Enumerate words - 254 entries

Enumerate the unique words in order.

  • Best score: 23
  • Best player score: 25
  • Position: #12 / 91
  • Number of attempts: 2
Harder than "abcd > a b c d" - 95 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: #8 / 43
  • Number of attempts: 4
Chinese Multiplication Table - 81 entries

Print a Chinese multiplication table in Vim. In China, every kid is asked to memorize this table. And thanks to the mono-syllabism of Chinese characters, it is not that hard. Printing the multiplication table is also a good exercise for programming beginners. For-loop, escaped characters, etc... There should be some special ways to print it in Vim.

  • Best score: 39
  • Best player score: 84
  • Position: #15 / 26
  • Number of attempts: 1
Groups magic - 158 entries

Regexp or macros for string converting: (a) -> ___ (abc) -> ____ (abcd) -> ______ All in the '(' replace to _ multiply by char count + ()

  • Best score: 13
  • Best player score: 13
  • Position: #4 / 93
  • Number of attempts: 3
Prefixes and suffixes - 635 entries

Generate all prefixes of "vimchallenge", then all suffixes.

  • Best score: 17
  • Best player score: 22
  • Position: #43 / 201
  • Number of attempts: 2
Python: Lots of function arguments - 119 entries

The function definition is too long for one line. The modeline helps you with some typical Python indent settings.

  • Best score: 6
  • Best player score: 13
  • Position: #9 / 50
  • Number of attempts: 2
Circle of Fifths with Sharps - 114 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: 24
  • Position: #4 / 38
  • Number of attempts: 3
Dehamlizing - 185 entries

Change this piece of HAML code back into erb

  • Best score: 32
  • Best player score: 32
  • Position: #3 / 72
  • Number of attempts: 6
NATO phonetic alphabet - 529 entries

Transform the series of words into a list.

  • Best score: 19
  • Best player score: 19
  • Position: #6 / 196
  • Number of attempts: 2
Shuffle and Sort - 229 entries

The values where sorted incorrectly. Get them back to how they are supposed to be

  • Best score: 17
  • Best player score: 17
  • Position: #6 / 67
  • Number of attempts: 4
SFD-ROC: Tic-Tac-Toe - 159 entries

Tic-Tac-Toe You are 'X', and it is your turn. Stop 'O' from winning, and complete the game. Draw a diagonal line through your winning row of three X's.

  • Best score: 25
  • Best player score: 25
  • Position: #3 / 54
  • Number of attempts: 3
SFD-ROC: The Quick Brown Fox - 193 entries

Someone has vandalized our text (again). Please fix to read: The Quick Brown Fox Jumps Over The Lazy Dog.

  • Best score: 24
  • Best player score: 28
  • Position: #39 / 106
  • Number of attempts: 1
The Quick Brown Fox Jumps Over The Lazy Vim - 420 entries

Someone has vandalized this text file and replaced the beginning character of one word in each line with a Big "X." Please remove the big X's, and fix each line to read "The Quick Brown Fox Jumps Over The Lazy Dog."

  • Best score: 8
  • Best player score: 10
  • Position: #26 / 192
  • Number of attempts: 1
The name of the game - 665 entries

End up with the name of the game.

  • Best score: 11
  • Best player score: 11
  • Position: #11 / 360
  • Number of attempts: 1
SFD-ROC: vimvimvim - 1606 entries

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

  • Best score: 8
  • Best player score: 8
  • Position: #1 / 446
  • Number of attempts: 2
SFD-ROC: Pipe Dreams - 115 entries

Move the pipes so they match the output.

  • Best score: 12
  • Best player score: 12
  • Position: #1 / 47
  • Number of attempts: 5
Stairs Indenting - 473 entries

Indent each line with <line number> whitespaces.

  • Best score: 12
  • Best player score: 14
  • Position: #74 / 197
  • Number of attempts: 1
Python to Ruby - 204 entries

Convert this Python code to Ruby. NOTE: This program likely won't run.

  • Best score: 24
  • Best player score: 25
  • Position: #3 / 61
  • Number of attempts: 4
maximun and minimun - 73 entries

Find the maximum and minimum of the rows.

  • Best score: 50
  • Best player score: 51
  • Position: #3 / 26
  • Number of attempts: 2
Cleanining up 80 column concatenated text - 203 entries

1. Put the whole query on one line, remove the concatenation operators 2. Remove the double spaces that appear a few times in the query 3. Use string-interpolated variable statementPid rather than the ugly concatenation

  • Best score: 31
  • Best player score: 31
  • Position: #6 / 79
  • Number of attempts: 5
Saving the hashes(#) - 2063 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: #75 / 480
  • Number of attempts: 5
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: 24
  • Position: #23 / 57
  • Number of attempts: 5
SFD-ROC: ROT13 Phonics - 101 entries

A is for apple, b is for ball, etc... This familiar phonics poem has been rotated 13 characters. Make the letter match the word.

  • Best score: 6
  • Best player score: 6
  • Position: #24 / 73
  • Number of attempts: 1
Create an alphabet diamond - 105 entries

Here's a brain teaser to keep things interesting...

  • Best score: 37
  • Best player score: 49
  • Position: #10 / 32
  • Number of attempts: 6
you're stuck on jQuery < 1.7 - 362 entries

replace calls to jQuery 1.7+'s `on` with calls to pre 1.7 `bind`

  • Best score: 25
  • Best player score: 25
  • Position: #3 / 113
  • Number of attempts: 5
Inconsistent real estate paste - 216 entries

Format a hand-typed real estate listing that uses inconsistent punctuation into four sections

  • Best score: 24
  • Best player score: 24
  • Position: #6 / 58
  • Number of attempts: 7
Vertical Limit - 2538 entries

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

  • Best score: 21
  • Best player score: 22
  • Position: #130 / 754
  • Number of attempts: 4
Exchanging Quotes - 858 entries

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

  • Best score: 30
  • Best player score: 31
  • Position: #30 / 230
  • Number of attempts: 3
Append semicolon after expressions - 1056 entries

Some lines need the semicolon, some don't.

  • Best score: 11
  • Best player score: 11
  • Position: #29 / 419
  • Number of attempts: 5
Remove semicolons after expressions - 654 entries

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

  • Best score: 6
  • Best player score: 6
  • Position: #44 / 263
  • Number of attempts: 3
switch variable - 5071 entries

how fast can you switch two variable ?

  • Best score: 11
  • Best player score: 11
  • Position: #131 / 1748
  • Number of attempts: 3
Format the output - 146 entries

Sometimes your standard out is a little hard to read. Take this multilevel hash and make it human readable.

  • Best score: 35
  • Best player score: 35
  • Position: #4 / 40
  • Number of attempts: 3
Calculate the table totals - 146 entries

Go ahead... commit the treachery of using vim as a spreadsheet.

  • Best score: 33
  • Best player score: 33
  • Position: #5 / 45
  • Number of attempts: 6
Ugly spreadsheet copy/paste to CSV - 1009 entries

convert an ugly spreadsheet copy/paste into a CSV format.

  • Best score: 19
  • Best player score: 20
  • Position: #18 / 193
  • Number of attempts: 15
Complete the hex array data (Part II) - 166 entries

Do not use external tools(e.g. tac, seq) [My interpretation of Rule #7]

  • Best score: 20
  • Best player score: 22
  • Position: #32 / 69
  • Number of attempts: 4
imports alignment (python) - 700 entries

Align as one import per line.

  • Best score: 17
  • Best player score: 17
  • Position: #33 / 198
  • Number of attempts: 7
Generate Fibonacci Numbers - 280 entries

Use your super vim powers to generate Fibonacci Numbers.

  • Best score: 19
  • Best player score: 19
  • Position: #10 / 100
  • Number of attempts: 7
Rotating Philosophers Problem - 410 entries

Can you help the philosophers find a good place to sit before they get five forks and spaghetti?

  • Best score: 29
  • Best player score: 29
  • Position: #21 / 166
  • Number of attempts: 2
Before there was Farmville... - 101 entries

There was old MacDonald. For my toddler. The first Vim sing-a-long?

  • Best score: 156
  • Best player score: 156
  • Position: #1 / 49
  • Number of attempts: 9
Overall Vimgolf Rank - 216 entries

Suppose you are trying to figure out what your overall rank is at Vimgolf(the sum of all the ranks you got), and as a Vim ninja you decided to use Vim to do the job. Your solution should work for every Vimgolf profile page(The actual input file for this challenge is my Vimgolf profile page). So, direct answer insertion is considered cheating.

  • Best score: 21
  • Best player score: 31
  • Position: #34 / 59
  • Number of attempts: 4
Turn this csv list into queries - 252 entries

Transform each line of this csv file into a MySQL-ready INSERT query.

  • Best score: 98
  • Best player score: 107
  • Position: #26 / 101
  • Number of attempts: 3
Linear congruential generator - 142 entries

http://en.wikipedia.org/wiki/Linear_congruential_generator

  • Best score: 28
  • Best player score: 30
  • Position: #23 / 53
  • Number of attempts: 4
Reverse characters in a line - 771 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: #50 / 265
  • Number of attempts: 1
PEP8 Python Wrapping Comments and Code - 210 entries

According to PEP8, long flowy text and code should have different max line lengths. Code: 79 characters max Long flowy text: 72 characters max

  • Best score: 21
  • Best player score: 23
  • Position: #4 / 67
  • Number of attempts: 6
Reformat most common surnames - 717 entries

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

  • Best score: 23
  • Best player score: 23
  • Position: #4 / 210
  • Number of attempts: 6
Change the content of a string - 1580 entries

This docstring is a complete lie. Fix it.

  • Best score: 22
  • Best player score: 22
  • Position: #83 / 588
  • Number of attempts: 5
Deleting folded text - 360 entries

The text below contains three folds. Delete them (and the text inside them). For example: 123 456 /*{{{*/ 789 /*}}}*/ 012 Should become: 123 012 Also, add `aoeuaoeu` to make sure small solutions don't get flagged as cheating.

  • Best score: 17
  • Best player score: 19
  • Position: #35 / 117
  • Number of attempts: 5
Sort and add attributes - 1451 entries

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

  • Best score: 33
  • Best player score: 33
  • Position: #119 / 563
  • Number of attempts: 6
Braces or Brackets? - 1015 entries

Someone forgot whether to use braces or brackets and you have to clean up their code!

  • Best score: 34
  • Best player score: 34
  • Position: #8 / 315
  • Number of attempts: 4
Whitespace, empty lines and tabs - 3665 entries

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

  • Best score: 16
  • Best player score: 16
  • Position: #3 / 787
  • Number of attempts: 8
Flodder-challenge - 1262 entries

Replace the text the most efficient and win!

  • Best score: 27
  • Best player score: 27
  • Position: #4 / 335
  • Number of attempts: 11
Simple text editing with Vim - 12811 entries

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

  • Best score: 13
  • Best player score: 13
  • Position: #104 / 3694
  • Number of attempts: 4
Reformat/Refactor a Golfer Class - 6982 entries

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

  • Best score: 28
  • Best player score: 32
  • Position: #36 / 1706
  • Number of attempts: 8

Contributed Challenges

maximun and minimun - 73 entries

Find the maximum and minimum of the rows.

create arrows in a list - 117 entries

Add arrow at same distance

Victor Ramirez
Twitter:

Backend developer who loves Open Source.

entered into 88 challenges

contributed 2 challenges