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]

24378 active golfers, 268013 entries, 424 challenges

Open VimGolf challenges

Create a pandoc compatible table - 136 entries

In [this vimcast][1], a featured gist from Tim Pope shows how to quickly make a simple table structure. How fast can you convert it to pandoc's markdown style? [1]: http://vimcasts.org/episodes/aligning-text-with-tabular-vim/

Convert pandoc unordered list to a numbered list - 131 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?

Long prime list - filter version - 19 entries

I've used the maximum input/diff/output size allowed by vimgolf to get a list of integers up to 1460 separated by newlines, and your goal is to only keep the lines containing primes. There are 232 of them I hope some of you will golf vimscript itself to create some function to run as a primality check for each line, which is a good exercise if you haven't done much vimscript yet! You're invited to also try copy-pasting and doing other non-smart text manipulation. Even more interesting would be to see a solution that uses text manipulation to do the filtering! Whether you use vimscript, normal-mode primality checks, or text manipulation, as long as the end result is valid, your answer will be valid! Let's see which method does better here. Best of luck!

Solve the Sokoban - 158 entries

A wink for all Vimgolfers that play Nethack too.

SFD-ROC: Tic-Tac-Toe - 124 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.

PEP8 Python Wrapping Comments and Code - 155 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

O Christmas Tree - 99 entries

Design a macro that makes trees grow (or ASCII triangles, if that's too hard).

Entries sort - 71 entries

It cames to my mind a weird idea : sorting parts of my .vimrc. Take few minutes to sort out this, it's easy !

Draw the Go board - 109 entries

which is a 19×19 lines board. Here we use ascii characters only for simplicity. See diff file to get a sense. (See also http://en.wikipedia.org/wiki/Go_(game))

Define to require - 113 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.

Refactoring useless Method away - 78 entries

Real-life challenge, convert a bunch of ifs to a switch statement

Sort yaml structures alphabetically by root key names - 25 entries

sometimes we want to sort structures alphabetically in yaml files

Turn a ninja to case-insensitive [Nn][Ii][Nn][Jj][Aa] regexp! - 40 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!

CSV to JSON - 143 entries

A search for shortest vimissh way to convert CSV to JSON.

Getters & Setters: Java - 141 entries

Boilerplate getters & setters - it's a tedious fact of life in Java, and probably the only thing that still pulls me back to an IDE. Perhaps someone knows a fast, pure vim way...

Fill visual area - 70 entries

Just have fun!

Overall Vimgolf Rank - 138 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.

Write Setters and Getters for PHP - 86 entries

Just simple automation of writing Setters and Getters like Doctrine might use.

Checkerboard case pattern - 106 entries

All the squares are white. Make some of them black. But only the right ones.

Changing URL path in CSS - 111 entries

What's the quickest way to swap out all the URLs in a CSS file? Is it wasted keystrokes using look-behinds and look-aheads? (I'm sorry for the delete/report--I made a mistake with the last one requiring an ugly search for graphic to replace with images. I just intended this to be a simple search and replace that might possibly generate some macros or normals solutions that are quicker)

Extract text from xml - 101 entries

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

Happy New Year! - 129 entries

This is a simple new year's challenge.

Complete the hex array data (Part II) - 123 entries

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

The Universal Declaration of Human Rights, Article 1 - 128 entries

Somebody's got this slightly muddled up. See how quickly you can fix it. (I made this to experiment with buffers. I'm not actually sure whether this is faster with buffers or without.)

Rail fence transposition cipher - 63 entries

Solve a rail fence transposition cipher using vim. This ciphertext was created using two rails. Use vim to transpose the text and recover the original quote.

Calculate the table totals - 105 entries

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

Sudoku table - 55 entries

Make this simple sudoku table look nice and legible.

Ninjas Leaderboard - 84 entries

The two lines in "Start file" has an obfuscated email address. Second line give an index (from 1 to 30) to the chars list of the first line, for example, the first char of email (n) is in position 25, second char (i) is in position 19 and s.o.

Double and switch - 36 entries

Aaaanother case switcher

Letters are numbers - 123 entries

Letters and numbers are interchangeable. A lot of programming languages give you simple ways to convert individual letters to hex, binary and decimal but does Vim?

Printable ASCII characters - 95 entries

From a blank input, print all 95 printing ASCII characters one per line, from space to tilde.

Comparing scores - 68 entries

If Alice and Bob both did the challenge, put their entries together in the top paragraph, so we can compare their scores more easily.

Land of the Lost - 60 entries

Enter the tabs below the lyrics

Word Blender - 118 entries

The insides of long words seem to have been run through the blender. Can you fix this famous tale, brave knight?

SFD-ROC: Pipe Dreams - 93 entries

Move the pipes so they match the output.

Format the output - 95 entries

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

Replace Parameter with Explicit Methods - 61 entries

Implementing the methods of a Java Interface

Square numbers - 57 entries

Boring math puzzle.

paste indent correction - JS - 75 entries

You copy some javascript code from a website and paste it into vim, it does not look good!

Converting group lines from format A to Format B - 20 entries

Convert from one format to another

Linear congruential generator - 104 entries

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

Flatten repo - 22 entries

For each git repository (<project> tag) translate name attribute to flatten directory structure. Add path attribute if missing (because checkout hierarchy must be kept). #xml

Roman numerals - 57 entries

Use the substitutions on top to convert unary to Roman numerals.

It's a factor - 75 entries

Flaunt your macro prowess by factoring some numbers. Too hard? It takes less than 30 strokes, I promise.

Remove Accent off the Letter - 100 entries

Remove all the accent from extremely accented statements.

HTML formatting: vertical alignment for readability - 59 entries

We did this a VimGolf challenge at work and now that we have finished I want to see if you guys can come up with something even better than we could. Our best solution was 44 keystrokes.

Sierpinski's Triangle - 79 entries

Build the famous fractal, Sierpinski's Triangle.

Chucking wood - 75 entries

An exercise in compressing repetitive text. For this challenge, any entry that uses keys outside the main row (such as arrow keys, Home, End, Delete, etc.) will be removed. (Esc is OK, though you should be using C-[ anyway.)

Not enough Ps - 48 entries

Different type of code

Lower cased and dashed strings - 42 entries

As I have to generate big fixtures files, I wanted to find a way to format input data the way described by start and end files. Especially the lower-cased-and-dashed ids Not so good to find a pure Vim way, that's why I submit this challenge ;)

VimGolf Chatter