3

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:

@a

:%norm! @b

@c

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

DJMcMayhem
  • 17,581
  • 5
  • 53
  • 85
lejonet
  • 167
  • 3

2 Answers2

4

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

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

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

Peter Rincker
  • 15,854
  • 1
  • 36
  • 45
4

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.

DJMcMayhem
  • 17,581
  • 5
  • 53
  • 85