replay a vim macro until end of buffer

VimMacros

Vim Problem Overview


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.

Vim Solutions


Solution 1 - Vim

Personally I would do

VG:normal @x

Edit: changed register to the one you specified.

Solution 2 - Vim

You can do (in command mode)

:%normal @x

Solution 3 - Vim

make recursive macro:

qa@aq

ex:

qa0gUwj@aq

It'll UPCASE first word from current line to the end of file with single @a. But make sure "a register is empty:

let @a=""

Solution 4 - Vim

999999@x, unless you have a very large buffer...

Solution 5 - Vim

From vim wiki, shortened version: qqqqq to record the macro @qq to finish recording @q to execute it (and will run till end of the file)

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionKevinView Question on Stackoverflow
Solution 1 - VimRandy MorrisView Answer on Stackoverflow
Solution 2 - Vimryan_sView Answer on Stackoverflow
Solution 3 - VimMaxim KimView Answer on Stackoverflow
Solution 4 - VimPeterView Answer on Stackoverflow
Solution 5 - Vimuser3499436View Answer on Stackoverflow