tags:

views:

322

answers:

4

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.

A: 

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

Peter
why not just `%:normal @x` or `1,$:normal @x`?
Nathan Fellman
this is definitely the more elegant solution - I guess `99999@x` is just the natural thing you come up with when you're in a hurry :)
Peter
Won't 9999999@x run it many times on the last line unless you have exactly 999999 lines?
David Oneill
+1  A: 

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=""
Maxim Kim
+3  A: 

You can do (in command mode)

:%normal @x
ryan_s
+5  A: 

Personally I would do

VG:normal @x

Edit: changed register to the one you specified.

Randy Morris
Nice one. I like that this solution operates on only the selected area.
Kevin