vimtricks.wiki Concise Vim tricks, one at a time.

How do I see what keystrokes a macro contains?

Answer

:reg a

Explanation

The :reg a command shows the contents of register a, which reveals the keystrokes stored in the macro. This helps you understand and debug macros.

How it works

  • :reg a displays register a's contents
  • Special keys appear as control characters (e.g., ^[ for Escape)
  • :reg without arguments shows all registers

Example

:reg a
--- Registers ---
"a   I//<Esc>j

This shows macro a contains: enter insert mode, type //, escape, move down.

Tips

  • ^[ represents <Esc>
  • ^M represents <CR> (Enter)
  • ^R represents <C-r>
  • Use this to verify a macro before running it many times
  • You can then edit the macro with "ap, modify, "add

Next

How do you yank a single word into a named register?