No one:
Really no one:
Me: Last year I wanted to refresh my knowledge with VIM so I did a couple VimGolf

Everyday after work, for a month, I timeboxed 15min to try to make the latest exercise of the VimGolf. Sometimes I failed but I always learned something everyday.

Rural Post #1

Date: 19/10/2020 Challenge:

Applied a simple macro and delete backwards.

First solution:


After I tried to learn about running a command multiple times without using macros.

However I did learned about ranges (:help :range) and I was able to find the following solution

:.,$norm $bd0j


Prepend * to every non-blank line #2

Date: 20/10/2020 Challenge:

I could find a solution with a macro but this time instead, I decide to search for a solution using find and replace. While I could easily append a ‘*’ to the beginning of each line with: `:%s/^/*/` it will add a start also to the empty lines.

My first submission will be the last one but removing the stars that dont have any text afterwards


I also learnd that I can use the pipe | to concat commands.


Now what I really want is a way to find all lines with a text and append the star *


':v' - matches the negation of the regex
'^$ - Regex of all empty lines
norm! - Starts the normal input applied to all lines found that are not empty running after certain {commands}
I* - Inserts a start in the beginning of each sentence found


Add semicolons #3

Date: 20/10/2020 Challenge:

After the previous problem this one looks easier but do notice each line has a white space before, but is a matter of checking for a character before a end of line $


However this will replace the last character and is not what we want, we want to append a ‘;’

So why not user ‘norm’ with A then write the ‘;’




I did enjoyed this solution


:g/\S - is the Range, escaping S to select all lines instead of just the letter 's'
/s/$/;  - substitutes the end of each line with ';'

Replaces all lines with a new line that the end is replaced by a ;

Easy modification of ssh config #4

Date: 21/10/2020 Challenge:

This is an hard one for me, I always wondered if I can count and save a number with vim, it would be simple if I knew. So I needed to search for it.

If I know how to increment a value I can simply to a search command and insert it

Today I learned about ‘let’ it will allow me to set a var with a value.

The following vim comamnd will find all the ‘abc’ and replace with xyz_# given # will be an incrementing number starting 1

:let i=1 | g/abc/s//\='xyz_'.i/ | let i=i+1

Knowing this, I need to find a way to match all the lines I need and add the worker# to the end of that line.

For this challenge, `:%s/^host [^m]/` should be enough.

:let i=1 | g/^host [^m]/s/$/\=' worker'.i/ | let i=i+1

I learned something today!

This gave me the first highlight but a terrible score of 56. I think I can at least try to be under 30. But that would be more golfing than learning.

Still, looking at the entry of the person next to me (29 Points @Izmoqwy) I’m already learning some tricks:

i worker0<Esc>ld0qq3j$p<C-A>yawq5@qZZ
  • `ZZ` to exit
  • `d0` to delete from cursor to start



Simple, Practical, and Common #5

Date: 22/10/2020 Challenge:

This is really simple in terms of movemnt, since the new line we need to add in temp is only difference in numbers increment will take advantage of (increment) numbers, while for the new line of “New text.” We might just need to create 2 ‘o’ (new lines below) The easiest way I found out is yank a empty line and paste it 2 times.


Well… I dont need to yy and paste 2 times, I can simple press enter after writing in a new line, saving clics…

A lesson learn from someone with slightly better score is of Anoop Kumar that is solution was:

6GYpf6R7 11<Esc>3joNew text.<CR><Esc>ZZ

He used
- '6G' goto line 6
- 'Y' instead of yy
- 'f' to find the number 6
- 'R' to start replacing the next caracters and writing 11 instead of <C-A> eleven times


Box it #6

Date: 24/10/2020 Challenge:

Repeating a insertion of a character is simple but to determine how many they should be is the interessting part. I need to search how to count the number of caracters and save it to reuse. This is my first exercise, knowing the golf challenge can be jsut count by hand.

We can use `:%s///gn` to count the number of characters. Unfortunatelly doesnt work to set in the ‘let i = …’ going to search

One thing I didn’t saw… the word changes from ‘is’ to ‘was’ need to be more carefull and read everything. For this I can use the find ‘f’ and then replace, I want to delete the caracter and write ‘was’

So this is my first attempt

O#<ESC>vy30pjI# <ESC>fsi<delete>wa<ESC>A #<CR><ESC>31p:x


Satisfy the go Linter #6

Date: 24/10/2020 Challenge:

At first look I will try a combination of macro with line change, will need to use ‘P’ to past upwards and ^ to move to beginning of non white characeter

Something I learned with other challengers is to remind to use of ‘’ for code completion on the wrods TODO and Debug


One number per line #7

Date: 24/10/2020 Challenge:

Full disclousure, I learned how to solve this challenge when I was searching for tutorials in youtube and foun the following one:

This video taught me how to save numbers in the register (same as delete and yank) and that anything separated in an array will be printed out each in one line. The solution presented in the video gives out a score of 14 that is the maximum. Could I do better? I really don’t think so, not even close…

Nevertheless I’m here to learn and so, the video taught me about:

  • ‘"=’ to enter something in the register
  • ctr-r to add something to the register
  • ctr-a to past the selected into the register

Result: N/A

Yo to Hello #8

Date: 26/10/2020 Challenge:

This is a basic one, can I make it to 10 strokes? Well, writing hello is 5 strokes but I can avoid writing the last ‘o’ if I do a replace Y and write. This means using the ’s'

AH! Though it was simple but, I’m adding a new line at the end, so my subission ends up with a last , meanhing a new line.. Interesting. I was completely wrong! The idea was to ADD a new line… So my solution ended up adding a ‘o’ and save but it costed me more keystrokes


I’ve now learned some new tricks to avoid writing the extra keystrokes, such as the following



Extended Shell Script #9

Date: 27/10/2020 Challenge:

This challenges seems to be a mix of duplicating lines and incrementing numbers, while the incremention can be a simple replace to simplify.


Didn’t notice that some `pcc` turns into `pcg`. So for this I’m thinking in a macro that change in the current line from `pcc`to `pcg`


Score of 67 not enough. Lets run the macro with a search & pattertn


Forgot to change the third line to pcg-2…

Now Ihave the idea of concatenating 2 macros


This was harder to replicate than any other XD

Lesson Learned is that there are different outputs for `p` and `P` when pasting multiple lines and that it is nice to concatenate macros.

To improve upon this I might work with editing registers “, but still it was a good learning

Result: 64

Just the middle #10

Date: 28/10/2020 Challenge:

Leaving just the lines with number should be a find & replace of lines without numbers. Lets see what I can do with 7 strokes. Knowing 2 are reserved to exit (:x or ZZ)

:v/\d/d<CR>ZZ` - 10 keystroke

v - All lines that does not match
\d - All numbers
d - delete

This solution gives me 10. I might do better. Will a simple and direct solution be better


Well, this is 8 keystrokes. Submitted!

Q: How can I shorten it? Is there a negation of interval? Well I can try use negative range. Delete all from -3 to line 2.

  • Doesnt work, only if there are already lines before.

Q: How about simple range delete?



I decided to look the answers and seems that there is a spam of the following 7 keystroke answer:


At first I didn’t understood it, it does work, I tried it. It is smart that it will write the solution and quit So taking it little my little.

) - Jumpts to the next sentence, this means will jumpt to the first line with a number. 3: - Will mark all the next 2 lines with numbers that we want to save, it even shows the folling starting command `:.,.+2` wq! - Will then this file with only the selected content and quit

Result: There are too many responses I can’t find my submission xD

Remove lines containing the word ‘reader’ #11

Date: 29/10/2020 Challenge:

The goals is to remove the lines with word “reader” seems a find & delete, can I do it in 9 keystores. I did learned the trick of selected only the lines we want and :wq! to save. Seems that this will be the case, will first count how many it will cost if I do a simple one

:%s/reader/d/g<CR>ZZ' - 17 ...

reader - 6 keystores, how can I imporve to only use 3. This means to go back to the basis and simples delete the lines we want This means keep line 1 and 5 delete the rest.

ddjd3djd2dZZ` - 12 keystrokes

Result: 12

Replace pattern with 1,2,3, … on each line #12

Date: 31/10/2020 Challenge:

Replacing all $ in each line with an increasing number. This at first looks like a concatenation of macro and copy paste.

Welp, this even with register I cannot solve it, since I took more than 30min I am stopping for now. I leave my notes.

@a - Search for the first $ and replace it by 1 - f$s1 @s - Saves the current number, searches for next $, replaces it by +1 and moves to the right with l - ylf$s��a"0p

Result: N/A

Words in parens #12

Date: 02/10/2020 Challenge:

All words in parenthesis, looks for a job for search for words and add the parenthises. Let me check my first solution, keystroke

So my idea was to run a command to all words (\w), however I’ve learn that the `g` command will only run it per one occorrence of word in each line. The following solution is not enough

:g/\w/exec "norm i(\<ESC>ea)"

I’ve learned something awesome in the `:help case`. Search groups. See this:

So an answer for this problem can be something like:


I’m kinda happy with this but 23 keystrokes :(

Result: 23

A HAPPY NEW YEAR 2014 ! #13

Date: 03/11/2020 Challenge:

Basically to replace END WITH for NEW and increment the 3 of 2013.


Result: 15

Line under headers #14

Date: 04/11/2020 Challenge:

Interesting challenge since I’ll need to know the amount of characters the word has, after I remove the ## The first idea is after removing with dw the ‘##’ I’l copy the word and paste it under to then apply a search and replace to the line.


And again I didn’t noticed that some of the text changes

To -> Are Underline -> Underlined


I might be able to improve upon this, but the exercise is done.

Result: 39

Com(m)a Trouble #15

Date: 05/11/2020 Challenge:

At first seems dauting but should be a matter of deleting ’d' and pasting back ‘P’ with some commands.


33 sure there is more margin for improvement, hope my future me knows better :hug:

Result: 33

Bad Copy Syntax #16

Date: 06/11/2020 Challenge:

For this exercise I might be able to use % to navigate and move the last word of the line. Or simply to a nice find & replace.

No success so I will use a combination of macros and movement. Such as % to jump to the second parenthesis.


I learn with:

That the + navigates to the begiining of the next line.

Result: 21

HS Final exam vimgolf #17

Date: 09/10/2020 Challenge:

For this I’ll use a combination of macro with appending to a register. I’ll add the parenteses with

:%s/\d\d/(&), /g - to add parenthesis

`gg` - to move up start macro to collect data and delete lines

qa"Sdwi(<Right><Right>), <Esc><fd-61>v^"Sdddq11@a"spxxZZ

Result: 33

Swap Number Pair #18

Date: 10/11/2020 Challenge:

For me looks like a search for all parenthesis and reversing the contents. With the ‘magic’ search of \v in the regex

:%s/\v(\d+), (\d+)/\2, \1/g<CR>ZZ

Could I do something with registers? Let me thing a bit since this was a fast one to accomplish. Do remember that ‘f’ can go through multiple lines. so I can cycle through all open parenthesis [

Result: 30

Vice versa #19

Date: 11/11/2020 20:00 Challenge:

Execise is the simple replace places of two words.


(5min) The last slash isn’t necessary, could save 1 keystore. How can I improve?

I felt inspired


Result: 16

Put a cross in the square #20

Date: 12/11/2020 Challenge:

Skipping this exercise since I already seen a possible solution but the other participants. I’m happy to learn something, where here the trick is to to use replace ‘r’ and first fill up down, then down up.

Result: N/A


Applying same text modification in several lines #21

Date: 12/11/2020 Challenge:

Sounds pretty simple, lets see in how many keystrokes i’m able


Wonder how I could improve upon this.

Result: 16

Simple Text Editing with Vim #22

Date: 14/11/2020 Challenge:

Starting the first ‘#’ copy the line below and replace the one under with it. I might well have a macro starting at #.


I ended up moving 3j instead of /#

I did now learn something with the other challengers, I could use the ‘|’ together with :g to duplicate lines and delete what is not needed.


Result: 14

Date: 17/11/2020 Challenge:

The idea here is to grab the url and the exit, might as well se if it works with a simple f&s lets see how many keystrokes that is.


But i could at least ommit some characters:


Dropped search and replace and tried something different


Result: 31


Date: 18/11/2020 Challenge:

Add parenthesis and wrap each line with quotes. There must be a key to move between non empty lines and then is a matter of creating a macro to add the quotes.

A (<Esc>qaj^D<Esc><fd-61>a""<Esc>Pq4@aj@ao<Esc><BS>ji)<Esc><fd-61>ZZ

Result: 33

One to Ten #25

Date: 19/11/2020 Challenge:

Creating one to ten numbers for me is a combination of copying and incrementing with C-a Since I was having some dificulties starting in 1, I think it is easier if I start in 10 and use capitalized P to past up and use together with a macro.


This challenged was based on a reddit post, that I took a look after I submitted my result. Learning quite a bit with the first comment

Result: 16

Swap values inside brackets#26

Date: 20/11/2020 Challenge:

Don’t have much time to think, its friday and 23:39. lets dooo this


There is clearly room for improvement since I even did a mistake with the `14j` but no time now. I wanted to practice a bit and do one more exercicse

Result: 27

xrandr outputs and dashes #26

Date: 21/11/2020 Challenge:

Done without thinkg, there most be room for improving since the top is 12 keystrokes

17 key strokes `qaj3wei-0q11@aZZ` Since I even did a mistak of using `3we` instead of only `3e` There most be a way to run a macro in all lines with out the ‘qa’ and ‘q’.

Looking at other challenged, I leard the following:

j:,$norm 3ei-<CR>ZZ

The comman will run the command in every line. The comman is needed to run in every line and to move to beggining of the line before running the normal command.


For every number between 1-3 add a dash before it, `&` means the matched texted. Here he didn’t needed the last `/` Also, he could have used `\d` since this command will only run in the first match of each line, saving quite a bit.

Now thanks to all challengers and learning from them, I got the minimum score of 12 with `:%s/\d/-&ZZ`

Result: 12

Swap values #26

Date: 23/11/2020 Challenge:

For this try I will use a register to save a delete text, just because I’m tired and I want to see the result and then, since I have a bit of time, see what I can improve on a second go.

w"adt,f=D"apF,PZZ - 17 keystrokes

Curious that no one with a keystroke similar to mine used one register. Now, how can I improve upon this?

Well I might be able to use the reserved registers for the effect. For example, if I Visual delect and delete, it will replace what is selected with what I delected but save in the ‘yank the removed text, where then I can use ‘P to paste the result! Lets see how many keystrokes this is.

wdt,f=v$pF,PZZ - 14 keystrokes

Notes: I really liked the idea of Cristian He uses a mix of auto-complete with search next with * to get to the objective. Saving 1 keystroke in the process. Should have also remembered that E jumps until the end of the sequence of non-blank characters, separated with white space. This might help me. improve my score

Result: 14

Enumerate Bullets #27

Date: 26/11/2020 Challenge: 15min challengesgogogogo

Just learned an important lesson:

Instead of rellying on search forward, I can start from the end and go down the numbering, with a mixture of using ? to search backwards and a macro.

Gs13.<Esc>vbyqa?- <CR>vpvb<C-X>vwyq11@aZZ

This solution however does not add the leading 0 to numbers less than 10

Gs13.<Esc>vbyqa?- <CR>vpvb<C-X>vwyq2@aqs@ai0<Esc><fd-61>q8@sZZ

Result: 44 — Terrible.. :(

Basic Renumbering #28

Date: 01/12/2020 Challenge:

Resources used

Used a mix of Visual Block with global a nice trick like this:

Select with visual block and 1 g C-A


Result: 23