vim Macros Editing a vim macro


Sometimes you will make a mistake with a lengthy macro, but would rather edit it than re-record it entirely. You can do this using the following process:

  1. Put the macro on an empty line with "<register>p.

    If your macro is saved in register a, the command is "ap.

  2. Edit the macro as needed.

  3. Yank the macro into the correct register by moving the cursor to the beginning of the line and using "<register>y$.

    You can re-use the original register or use another one. If you want to use register b, the command is "by$. or by using "<register>d$ (deletes the unused line)