Step 4 of 6

Macros live in registers

Macros live in registers

So far Q and q have been using a register called @ — that’s what the [@] flag was telling you. Helix doesn’t have a special “data store” for macros: it re-uses the registers you already know from copying and pasting. A recording is just a string of keystrokes stored in a register, and q reads it back out.

That means the " register prefix works exactly as it does for yank and paste. "aQ starts recording into register a, and "aq replays whatever is in register a. Any letter will do, so you can keep several macros around at once instead of overwriting the one in @.

Let’s prove it in the editor. Work through the checklist below. Record a tiny macro into the a register and replay it with "aq. Then press " on its own: the register popup lists a and the keystrokes it holds — even the final Esc, which Helix writes as <esc>. Esc dismisses the popup.

  1. Start recording into the a register Press "aQ — the statusline says Recording to register [a].
  2. Append an exclamation mark while recording This sentence could use one — press A!, then Esc.
  3. Stop recording Press Q.
  4. Replay from the a register Press "aq.
  5. Peek at the registers Press " — the popup lists a as A!<esc>; Esc closes it.
Start recording into the a register Press "aQ — the statusline says Recording to register [a].

Next: Append an exclamation mark while recording

Loading editor…