Macros are incredibly powerful
Macros are definitely up there among Helix’s most powerful features. The core problem that macros are trying to solve is that nobody likes making repetitive edits — it’s boring, error prone, and can take a very long time. Macros help us here by automating away routine edits, minimizing legwork.
The great thing about them is that they’re conceptually very simple, and we don’t have to learn very many new concepts to start using them effectively.
Helix’s macro functionality lets us record a sequence of keystrokes and replay them back at will. You can capture complex editing jobs with a macro, and replay it on demand to repeat the edit.
First, let’s learn how to record a macro. To start recording, hit Q
(capital) in normal mode. Helix tells you it’s recording in two places: a
Recording to register [@] message in the statusline, and a small [@]
flag in the bottom-right corner that stays put for as long as the recording
runs.
Once you’ve started recording, start editing. Your keystrokes will be stored
inside the macro and you’ll be able to replay them later. Once you’ve
finished with your edit, hit Q again to stop recording.
Let’s try it in the editor — work through the checklist below. There’s a
little TODO list in the buffer; start recording with Q, mark the first
item as done, and hit Q again to stop. We’ll learn how to replay this kind
of macro in the next section.