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]

23506 active golfers, 252060 entries, 410 challenges

Open VimGolf challenges

Fun With The Diagonal - 79 entries

change the lowercase characters on the main diagonal to uppercase

Hidden Message - 44 entries

Find the hidden message and replace all other characters with spaces.

Test everything! - 111 entries

... and build the desired input data structure. Transform a list of values into a non-trivial format.

Java Array2List - 210 entries

Convert an java array initializer into a list.

NBCU Weekly Challenge - #0 - 118 entries

One of our favorites lines here at NBCU! p.s. The first version of #0 was deleted due to me copy/pasting a HTML entity. Congrats to the one who figured that out, you are a true ninja warrior!

Refactor arguments into object argument - 156 entries

A relatively common Javascript refactoring.

Winning streak - 105 entries

Make the number on each line equal the consecutive L's or W's.

Shuffle and Sort - 171 entries

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

Assign list - 145 entries

Assign list elements to matrix

Block Fun 1 - 158 entries

Manipulate the columns to produce desired result.

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!

Cartesian product - 201 entries

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

Generate Fibonacci Numbers - 200 entries

Use your super vim powers to generate Fibonacci Numbers.

Another Mixed-Up Haiku - 196 entries

VimGolf ... a perfect evening?

It'ss tooo coold too typpe todaay - 194 entries

My hands are numb with cold. It's hard to type correctly.

Dehamlizing - 155 entries

Change this piece of HAML code back into erb

Assign numbers to fields - 82 entries

You are given a list of space-separated strings. Add an increasing numeric prefix to each one.

Separating firstname & lastname - 96 entries

Seperate named with equal tabs.

PHP <--> Java class conversion Part 1 - 178 entries

Convert this tiny php class to adequate java one.

swap or reverse - 87 entries

Try to swap or reverse the line as needed.

Piphilology - 114 entries

Piphilology comprises the creation and use of mnemonic techniques to remember a span of digits of the mathematical constant π. http://en.wikipedia.org/wiki/Piphilology

ASCII Art - 68 entries

how good are you with simple regex?

constructor - 161 entries

coding a constructor for a simple class

Aligning function arguments to match a specific coding style - 151 entries

Most projects have specific coding style guidelines. In this case, the argument list must be broken into a new line for each argument, with the argument names right aligned, taking into account pointers.

42-header - 28 entries

Rush 42mexican-standoff at 42 school

formatted text to markdown - 173 entries

You're converting some posts from an old blog to markdown. The formatted text is far closer to the finished product than the html markup, so it seems like a good place to start. Word wrapping seems to be the main area for optimization.

Turn this csv list into queries - 181 entries

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

Complete the hex array data - 174 entries

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

Multiplication table. - 171 entries

Create a multiplication table.

SFD-ROC: The Quick Brown Fox - 140 entries

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

Groups magic - 134 entries

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

Unwrap the text of an email message - 135 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?

REDRUM - 131 entries

If you remember "The Shinning", the first time you saw the bloody word REDRUM you probably thinked "What the Hell is that?" Well, then you know that you need a little help from a looking-glass to make sense of it. Now it's time to use vim like a mirror to reveal the message.

Sort yaml structures alphabetically by root key names - 25 entries

sometimes we want to sort structures alphabetically in yaml files

Inconsistent real estate paste - 140 entries

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

Winding path - 91 entries

It's a maze, but the bad paths have been blocked off. Mark the correct path.

Circle in a square - 125 entries

Probably looks more like "Egg in a rectangle" in most fonts, but it's actually 23x23.

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/

Almost encrypted - 164 entries

Convert the first paragraph to be even less readable.

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

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.

O Christmas Tree - 99 entries

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

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!

Entries sort - 69 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 - 108 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

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

Fill visual area - 70 entries

Just have fun!

VimGolf Chatter