Hacker News new | ask | show | jobs
by lawn 768 days ago
Q or @ to execute a macro over all visually selected lines is a feature I didn't know about but sounds amazing.

All too often I create a macro that I want to execute many times, but it's hard to know how many. I've tried the guessing approach but that has a tendency to under- or overestimate.

3 comments

My general approach for macros that I want to execute many times is to end by going down a line (for sequential lines) or to end with a search for the next place that the macro can run. Then I can easily review the targets and run or skip on each.
I'll often visual select ("v" and motion) and then ":norm @a" to run the macro on all the selected lines.
You might find relative line numbers useful. `set relativenumber`
I already use relative line numbers but they don't help when the lines continue below the window.