Thursday, December 15, 2011

tiny vim helpers - edit end of every n line with vim

I needed to add a fricking quatation mark and semicolon after every line for hundreds of lines.
I used the following vim combo

qaA";1jq
here is what it means:
q: start recording this as a combo
a: the label of the combo
A: insert here (after the character) (i for before the character)
";
1j: go 1 line down (to the same spot, in my case, end of line)
q:stop recording the macro.

So I went to the end of the first line and did this (qaA";1jq)
and then this
100@a
meaning that repeat the macro a for 100 times.

I know it is very basic but there is some resistance to learning the shortcuts in me when it comes to vim.
Let this new bit of information and so much future time saved on vim, be a birthday gift from me to me.

No comments:

Post a Comment