I want to run a macro I just recorded in register "x
" on every single line of an open buffer, from my cursor to end of the buffer, in vim. How do I do that?
I know I can replay the macro n times:
15@x
...or just hold down @
until I reach the the last line, but I want to just hit a few keystrokes and be done with it.
Thanks in advance.
To replay the macro once, move the cursor to the next line and press @h where h represents the register on which you saved the macro. Notice that the macro automatically moves the cursor to the next line as required. This allows you to repeat its execution. To repeat the macro execution, press @@.
6) actually persists macros and named buffers automatically (by default, although I haven't looked for a way of turning this behavior off). Closing a Vim session will update the ~/. viminfo file with any named buffers / macros.
create an empty line, paste the register you are overwriting (if you're recording in the q register, it's "qp ), now quit the recording mode ( q ) select the line you pasted above (without end of line mark: 0v$h ; don't use V )
Personally I would do
VG:normal @x
Edit: changed register to the one you specified.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With