Macros

A macro in Vim is simply a sequence of recorded commands.

  • Q โ€“ Starts recording a macro. Perform actions, then press Q again to stop recording.
  • @a โ€“ Replays the macro recorded in register a.

๐Ÿ›  Editing a Macro

  1. Create a new buffer:
1
:new
  1. Paste the contents of the macro from register a:
1
:put a
  1. Edit the macro content:
  • A โ€“ Move to end of line in normal mode.
  • ^[ (Escape) โ€“ Exit insert mode.
  • J โ€“ Join the line with the one below.
  1. View all registers:
1
:reg
  1. Copy and paste the edited text back into register a:
  • “ayy โ€“ Copy the current line into register a.
  1. Run the updated macro:
1
@a