Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

replay a vim macro until end of buffer

Tags:

vim

macros

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.

like image 881
Kevin Avatar asked Aug 18 '09 05:08

Kevin


People also ask

How do you repeat a macro in Vim?

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 @@.

Do Vim macros persist?

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.

How do you stop a macro in Vim?

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 )


1 Answers

Personally I would do

VG:normal @x 

Edit: changed register to the one you specified.

like image 142
Randy Morris Avatar answered Oct 06 '22 12:10

Randy Morris