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

Change to ascending order - 14 entries

Change each line of numbers consistently from descending to ascending order.

  • Best score: 17
  • Best player score: 32
  • Position: #4 / 5
  • Number of attempts: 6
Generate an entry for each month - 72 entries

The input file contains a URI with a month in it. Generate the URIs for all the other months up to a couple of years

  • Best score: 27
  • Best player score: 56
  • Position: #18 / 24
  • Number of attempts: 3
Fix the git merge conflicts - 61 entries

Solve the merge conflicts in the Python file

  • Best score: 36
  • Best player score: 58
  • Position: #12 / 16
  • Number of attempts: 1
The Fibonacci Spacer - 41 entries

Split the words, remove punctuation and add spaces before each line following the Fibonacci sequence (0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89)

  • Best score: 25
  • Best player score: 108
  • Position: #15 / 16
  • Number of attempts: 3
Fix the Scala Method - 94 entries

Fix the missing semicolons and the Int type, ensure the floating point division, and remove the unnecessary return.

  • Best score: 9
  • Best player score: 22
  • Position: #4 / 34
  • Number of attempts: 3
Change class fields from camel case to snake case - 243 entries

This is the reverse of the previous challenge: https://www.vimgolf.com/challenges/9v006705493c000000000513

  • Best score: 18
  • Best player score: 23
  • Position: #36 / 63
  • Number of attempts: 2
Reorganize Pokémon - 261 entries

Change the format of the each line and sort alphabetically.

  • Best score: 18
  • Best player score: 21
  • Position: #25 / 72
  • Number of attempts: 5
Replace csv column if it's not empty - 92 entries

Replace the credit_score_percentile column with the value 0.0 but leave the empty ones untouched

  • Best score: 15
  • Best player score: 37
  • Position: #34 / 37
  • Number of attempts: 1
Change readonly files - 25 entries

Try to write a file that was marked as read-only.

  • Best score: 20
  • Best player score: 53
  • Position: #7 / 10
  • Number of attempts: 1
extract struct tag in go - 35 entries

Can you extract all struct tags in the fewest keystrokes possible?

  • Best score: 33
  • Best player score: 40
  • Position: #10 / 14
  • Number of attempts: 7
CaN yOuR ViM dO ThAt? #1 - 66 entries

Tsoding's famous "Can your Vim do that?" https://youtu.be/Bafo3hhheHU?si=DfcT4sUEMTSAevnx&t=1091

  • Best score: 41
  • Best player score: 45
  • Position: #12 / 28
  • Number of attempts: 2
Append leading hyphen count to each line - 47 entries

Append the number of leading hyphens to the end of each line.

  • Best score: 23
  • Best player score: 25
  • Position: #7 / 14
  • Number of attempts: 3
Move list of uuids into a SQL query - 64 entries

Take the list of UUIDs and use them as a filter in the where statement of a SQL query

  • Best score: 57
  • Best player score: 65
  • Position: #12 / 25
  • Number of attempts: 2
Markdown Blog Editing - 246 entries

Convert the given link text in start file to a markdown link list.

  • Best score: 30
  • Best player score: 42
  • Position: #26 / 61
  • Number of attempts: 5
Fix timezone format - 220 entries

Add the missing T and Z in the datetime field. There should be a T instead of the space, and a Z at the end of the datetime. `2024-08-31 18:32:00;` -> `2024-08-31T18:32:00Z;`

  • Best score: 15
  • Best player score: 17
  • Position: #33 / 73
  • Number of attempts: 3
Search different SQL column with similar where clause - 168 entries

Replace a column in the where clause and convert all numbers from text to numeric, by replacing the leading 0 with the code 359.

  • Best score: 22
  • Best player score: 25
  • Position: #24 / 45
  • Number of attempts: 2
Remove adjacent duplicates - 437 entries

Try to find a way to remove adjacent duplicate letters.

  • Best score: 19
  • Best player score: 23
  • Position: #52 / 116
  • Number of attempts: 3
Rearrange array to single level - 1267 entries

The goal is to flatten the array into a single list and remove any empty elements.

  • Best score: 14
  • Best player score: 59
  • Position: #185 / 202
  • Number of attempts: 2
Rearrange array to one line - 588 entries

Rearrange the array content on only one line, and remove trailing commas

  • Best score: 13
  • Best player score: 30
  • Position: #125 / 142
  • Number of attempts: 2
Copy punctuation - 483 entries

I want to copy the last line’s brackets, quotes, and commas to each line. How?

  • Best score: 19
  • Best player score: 145
  • Position: #114 / 119
  • Number of attempts: 1
Column wise pasting - 168 entries

Make a table from 3 columns

  • Best score: 17
  • Best player score: 44
  • Position: #33 / 36
  • Number of attempts: 1
New teacher - 884 entries

Update the details of the new CS teacher.

  • Best score: 19
  • Best player score: 21
  • Position: #39 / 189
  • Number of attempts: 8
months to html list items - 996 entries

Turn the months into list items.

  • Best score: 22
  • Best player score: 25
  • Position: #120 / 269
  • Number of attempts: 8
Quicksort - 1923 entries

We need the numbers in the first row sorted as quickly as possible! Be careful not to disturb the data below the divider though: that must remain unchanged.

  • Best score: 6
  • Best player score: 24
  • Position: #257 / 425
  • Number of attempts: 3
Populate 3D bone names list - 623 entries

Ran into this at work, excited to see how this gets optimized

  • Best score: 21
  • Best player score: 26
  • Position: #64 / 161
  • Number of attempts: 6
Find fix point of cos - 1392 entries

Write a function to find the fix point of cos. It is not a good code; It is just to use vim. Inspired by the excellent https://mvanier.livejournal.com/2897.html about the Y combinator.

  • Best score: 14
  • Best player score: 15
  • Position: #243 / 409
  • Number of attempts: 2
Surround the 'z' character with brackets, quotes, and print as formatted string. - 551 entries

Surround the 'z' character with brackets, quotes, and print as formatted string.

  • Best score: 17
  • Best player score: 17
  • Position: #233 / 307
  • Number of attempts: 3
Paste a column after a column - 2526 entries

This task is very common while using multi-cursor. What is the elegant vim way ?

  • Best score: 14
  • Best player score: 24
  • Position: #382 / 551
  • Number of attempts: 3
Filter number combinations that don't add to 11 - 406 entries

Append the sum of each line to its end, alongside an equals sign, and remove any that do not sum to 11. The ordering of lines should stay the same. Note that the combinations are semi-arbitrary and not all 4-number combinations are present in the file.

  • Best score: 27
  • Best player score: 27
  • Position: #44 / 116
  • Number of attempts: 4
HS exam question - 1578 entries

Convert the data to a python dictionary

  • Best score: 47
  • Best player score: 61
  • Position: #133 / 416
  • Number of attempts: 6
Reformat symbols in list - 1614 entries

Saw this in some lecture, easy reformatting using multiple cursor in VS Code

  • Best score: 24
  • Best player score: 32
  • Position: #208 / 347
  • Number of attempts: 3
delete swap - 1776 entries

delete all swap

  • Best score: 5
  • Best player score: 5
  • Position: #375 / 550
  • Number of attempts: 6
Fix the shell script! - 2544 entries

Fix the shell script with the fewest keystrokes!

  • Best score: 26
  • Best player score: 42
  • Position: #425 / 589
  • Number of attempts: 2
hello-world-vimgolf - 2499 entries

Simple number generation

  • Best score: 10
  • Best player score: 13
  • Position: #501 / 708
  • Number of attempts: 3
Making 3 line function a one liner. - 328 entries

Simple challenge for frequent action while programming.

  • Best score: 4
  • Best player score: 4
  • Position: #180 / 205
  • Number of attempts: 1
Modernise code - 1396 entries

Modernise and clean up some C++ code.

  • Best score: 34
  • Best player score: 44
  • Position: #184 / 322
  • Number of attempts: 2
Satisfy the go linter - 2391 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: 28
  • Position: #354 / 471
  • Number of attempts: 5
Add quotes to ansible playbook - 952 entries

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

  • Best score: 8
  • Best player score: 10
  • Position: #255 / 304
  • Number of attempts: 4
Multiline to Single Line - 700 entries

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

  • Best score: 5
  • Best player score: 5
  • Position: #256 / 302
  • Number of attempts: 3
Data reformat - 294 entries

Reformat this copy-paste data! #csv

  • Best score: 36
  • Best player score: 62
  • Position: #48 / 65
  • Number of attempts: 1
xrandr outputs and dashes - 704 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: #150 / 221
  • Number of attempts: 9
Swap values inside brackets - 2493 entries

Easy challenge.

  • Best score: 14
  • Best player score: 15
  • Position: #215 / 578
  • Number of attempts: 5
Unsemantic linewrapping - 928 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: 13
  • Position: #194 / 231
  • Number of attempts: 2
Applying same text modification in several lines - 2877 entries

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

  • Best score: 12
  • Best player score: 13
  • Position: #273 / 850
  • Number of attempts: 5
Bad Copy Syntax - 2033 entries

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

  • Best score: 18
  • Best player score: 21
  • Position: #307 / 524
  • Number of attempts: 2
remove lines containing the word "reader" - 3583 entries

easy stuff

  • Best score: 9
  • Best player score: 9
  • Position: #506 / 1161
  • Number of attempts: 3
From argument to object - 1505 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: #271 / 457
  • Number of attempts: 1
For all cases. - 161 entries

In this case... change it! :) Watch the line.

  • Best score: 8
  • Best player score: 9
  • Position: #97 / 106
  • Number of attempts: 1
Stairstep digits - 394 entries

Remove the evens. Double the odds.

  • Best score: 9
  • Best player score: 13
  • Position: #129 / 145
  • Number of attempts: 2
Simple addition - 326 entries

The right side of the equation is already there. We just need the left one now.

  • Best score: 12
  • Best player score: 15
  • Position: #109 / 122
  • Number of attempts: 2
create arrows in a list - 117 entries

Add arrow at same distance

  • Best score: 10
  • Best player score: 21
  • Position: #71 / 73
  • Number of attempts: 5
Create Leading Zeros - 241 entries

Create leading zeros only for id columns. Please use generic approach!

  • Best score: 23
  • Best player score: 49
  • Position: #70 / 82
  • Number of attempts: 2
Nesting SASS - 266 entries

Move a block inside another block and indent it

  • Best score: 9
  • Best player score: 18
  • Position: #83 / 96
  • Number of attempts: 1
lipsum lines - 278 entries

Convert a quoted block of text into strings in a list.

  • Best score: 28
  • Best player score: 32
  • Position: #58 / 95
  • Number of attempts: 5
Change part of a function name in multiple occurrences - 662 entries

Change the middle part of the function name in multiple places, preferably using the next and dot commands.

  • Best score: 14
  • Best player score: 17
  • Position: #165 / 208
  • Number of attempts: 1
unknown command - 167 entries

I want change 5 words

  • Best score: 7
  • Best player score: 34
  • Position: #77 / 87
  • Number of attempts: 1
Swap assigned value - 647 entries

Simple problem but looking for interesting solutions.

  • Best score: 10
  • Best player score: 11
  • Position: #195 / 254
  • Number of attempts: 4
Binary and Increment - 56 entries

Some numbers fun: not only increasing numbers but also increasing binary.

  • Best score: 22
  • Best player score: 28
  • Position: #11 / 20
  • Number of attempts: 1
VimGolfNight - 560 entries

Based on "The name of the game".

  • Best score: 12
  • Best player score: 12
  • Position: #296 / 347
  • Number of attempts: 1
Split the words - 363 entries

Add the spaces manually if you must, but if you use Vim's spell checking feature wisely, I think you'll save a LARGE number of strokes.

  • Best score: 18
  • Best player score: 38
  • Position: #68 / 110
  • Number of attempts: 6
attr_aligner - 3511 entries

Two attr keywords. Two separate indentations. Align the colons.

  • Best score: 19
  • Best player score: 19
  • Position: #183 / 698
  • Number of attempts: 4
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: #947 / 1078
  • Number of attempts: 1
Delete unwanted lines - 411 entries

Delete all lines which does not end in "o.."

  • Best score: 9
  • Best player score: 9
  • Position: #197 / 229
  • Number of attempts: 3
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: 19
  • Position: #42 / 50
  • Number of attempts: 3
Readable Rubyhash - 267 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: 23
  • Best player score: 30
  • Position: #74 / 95
  • Number of attempts: 4
NATO phonetic alphabet - 529 entries

Transform the series of words into a list.

  • Best score: 19
  • Best player score: 21
  • Position: #112 / 196
  • Number of attempts: 3
Switch function arguments - 2136 entries

How to switch two arguments of a function.

  • Best score: 11
  • Best player score: 11
  • Position: #198 / 662
  • Number of attempts: 6
Append semicolon after expressions - 1056 entries

Some lines need the semicolon, some don't.

  • Best score: 11
  • Best player score: 12
  • Position: #266 / 419
  • Number of attempts: 2
Ruby 1.9 hashes - 1244 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: 12
  • Position: #115 / 406
  • Number of attempts: 5
A Simple One - 1047 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: #586 / 662
  • Number of attempts: 1
Ruby 1.9 compat - 627 entries

Remember when Ruby supported `when <expr> :`? Well, it doesn't in 1.9, so let's make sure we use `then`, without ruining our lovely new hash syntax!

  • Best score: 14
  • Best player score: 16
  • Position: #141 / 233
  • Number of attempts: 3
Hatsuyume - 513 entries

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

  • Best score: 15
  • Best player score: 19
  • Position: #29 / 184
  • Number of attempts: 3
Turn this csv list into queries - 238 entries

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

  • Best score: 98
  • Best player score: 122
  • Position: #50 / 100
  • Number of attempts: 1
Reverse characters in a line - 757 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: 23
  • Position: #225 / 263
  • Number of attempts: 1
Reformat most common surnames - 698 entries

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

  • Best score: 23
  • Best player score: 33
  • Position: #133 / 208
  • Number of attempts: 3
Change the content of a string - 1567 entries

This docstring is a complete lie. Fix it.

  • Best score: 22
  • Best player score: 23
  • Position: #320 / 585
  • Number of attempts: 4
Sort and add attributes - 1436 entries

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

  • Best score: 33
  • Best player score: 34
  • Position: #383 / 559
  • Number of attempts: 3
Add fold markers to a .c file - 608 entries

Fold markers can make it easier to navigate source code. Add them to this .c file.

  • Best score: 30
  • Best player score: 36
  • Position: #113 / 181
  • Number of attempts: 1
Reconstruct the Sentence - 1487 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: #248 / 409
  • Number of attempts: 2
Braces or Brackets? - 982 entries

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

  • Best score: 34
  • Best player score: 37
  • Position: #65 / 313
  • Number of attempts: 3
Simple text editing with Vim - 12760 entries

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

  • Best score: 13
  • Best player score: 15
  • Position: #2126 / 3684
  • Number of attempts: 3
Reformat/Refactor a Golfer Class - 6942 entries

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

  • Best score: 28
  • Best player score: 34
  • Position: #323 / 1699
  • Number of attempts: 6

Contributed Challenges

Generate an entry for each month - 72 entries

The input file contains a URI with a month in it. Generate the URIs for all the other months up to a couple of years

Move list of uuids into a SQL query - 64 entries

Take the list of UUIDs and use them as a filter in the where statement of a SQL query

Fix the Scala Method - 94 entries

Fix the missing semicolons and the Int type, ensure the floating point division, and remove the unnecessary return.

The Fibonacci Spacer - 41 entries

Split the words, remove punctuation and add spaces before each line following the Fibonacci sequence (0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89)

Convert plain text into a markdown table - 20 entries

Convert the table to markdown to make it more usable

Replace csv column if it's not empty - 92 entries

Replace the credit_score_percentile column with the value 0.0 but leave the empty ones untouched

Change class fields from snake case to camel case - 134 entries

Change the class fields in this Scala class from snake case to camel case

Change class fields from camel case to snake case - 243 entries

This is the reverse of the previous challenge: https://www.vimgolf.com/challenges/9v006705493c000000000513

Replace markdown sections with numbering - 139 entries

Replace each section and subsection with their respective numbers

Nested JSON Flattener - 16 entries

Transform a deeply nested JSON structure into a flattened key-value format where each path is represented by dot notation

Fix the git merge conflicts - 61 entries

Solve the merge conflicts in the Python file

Swap columns and transform to CSV format - 6 entries

Turn this spreadsheet output into a CSV file but first swap the columns

Pablo Acuna
Github:

entered into 82 challenges

contributed 12 challenges