views:

744

answers:

2

I have a file with a bunch of lines. I have recorded a macro that performs an operation on a single line. I want to repeat that macro on all of the remaining lines in the file. Is there a quick way to do this?

I tried Ctrl+Q, highlighted a set of lines, and pressed @@, but that didn't seem to do the trick.

A: 

See this question: http://stackoverflow.com/questions/355907/how-do-i-repeat-an-edit-on-multiple-lines-in-vim

Can Berk Güder
This post doesn't tell how to apply a macro on multiple lines. It just says to record a macro or to perform a substitution on multiple lines.
j0rd4n
+11  A: 

Use the normal command in Ex mode to execute the macro on multiple/all lines:

Execute the macro stored in register a on lines 5 through 10.

:5,10norm! @a

Execute the macro stored in register a on all lines.

:%norm! @a

Enter :help normal in vim to read more.

Judge Maygarden
Adding a : first doesn't allow me to use @
j0rd4n
Yes it does. You type the whole thing on the line and then press enter.
Judge Maygarden
Ah, it was the norm! part that I was missing.
j0rd4n
Do you have any good place where I can read about "norm!"?
j0rd4n
Yes, :help normal in vim or the link I just added.
Judge Maygarden
Sweet - thanks aplenty!
j0rd4n
Anything to help a fellow non-emacs user!
Judge Maygarden
awesome! that saved a lot of time.
Vijay Dev