I have three macros that I have created separately over time. a performs a search and replace, b adds tags to every line and c appends text at the beginning and the end of the file.

I execute them like this:


:%norm! @b


How can I execute them in this order without starting each one separately?


Since you are using a macros why not use another macro to execute the other three!

let @q = "@a:norm! @b\<cr>@c"

Note: I am using :let to set the q register here, but you could just as easily record a macro with q, e.g. qq@a:norm! @b^M@cq (where ^M is pressing return).


You can execute all of them in a single normal command. For example:

:normal @a:%norm! @b^M@c

Note that ^M is a literal carriage return, and is typed by pressing <C-v><cr>, not the literal text ^M.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.