Part 2 · Everyday editing / 2.4

Undo, phrases, and macros

How to get back what you broke, how to type the same passage less often, and how to replay a sequence of keys. Phrases and macros have no keys in the default profile — you assign them yourself in the keymap editor.

Reading time about 10 min Audience Anyone who types the same thing twice Prerequisites 2.2 Version v1.0 ・ 2026-08-26
2.4.1

Undo and redo

Ctrl+Z goes back, Ctrl+Y goes forward, 100 steps each.

KeyActionMessage row
Ctrl+ZUndoUndid last action / Nothing to undo
Ctrl+YRedoRedid last action / Nothing to redo
  • Undo restores the cursor position too, taking you back to where the edit happened.
  • As long as you do not type anything new, you can redo your way forward again.
  • Typing after an undo clears the redo history — as in every editor.
  • Each tab has its own history (see 2.1.4).
Two things wipe the history
  • An automatic reload after an external change: the old steps no longer fit the new content, so they are dropped (see 2.1.7).
  • Closing the tab: the history belongs to the tab and reopening the file does not restore it.
Erya Classic redoes with a different key

Redo is Ctrl+Y in the default profile but Ctrl+R in Erya Classic — where Ctrl+Y deletes a line instead. This is the pair people press by mistake most often after switching; check the hint bar (see 4.1.2).

2.4.2

How big is one step

Usually one keystroke, except for five actions that count as one.

One keystroke, one step

  • Typing a character
  • Deleting one (Backspace / Delete)
  • One Enter
  • Cutting or deleting a line
  • One paste

So 100 steps is roughly 100 characters. Undo is a poor way to roll back a long passage you have just typed.

One step for the whole batch

  • Replace all (F6) — however many matches
  • Formatting (Ctrl+T)
  • Paragraph reflow
  • Inserting a phrase
  • Running a macro — no matter what it did

All five are “one command, wide effect”, so they are deliberately merged: one Ctrl+Z takes the lot back.

Byte editing has its own rule

Writing a byte takes two hexadecimal digits (high nibble, then low), and the two presses count as one step. See 3.3.6.

2.4.3

What phrases are for

Capture text you keep retyping, insert it with one key, and it advances to the next entry.

Phrases suit standard closings in correspondence, code templates, paths and names you type constantly, or a set of tags you insert repeatedly. What makes them unusual is that each insertion advances to the next phrase, so pressing the key several times lays out the whole set in order.

Phrase 1 Yours sincerely, Phrase 2 Prepared by: Phrase 3 (end of document) after the last one, the next press starts again at phrase 1
Figure 2.4.1 The phrase library is a cycle. Each insertion moves to the next entry, and the message row says “Inserted phrase 2/3” so you know where you are.
2.4.4

Capturing and inserting phrases

Four actions: capture, insert, load, save.

Action nameKey in ClassicWhat it does
capture_phraseF9Captures the selection, or the whole current line if nothing is selected.
insert_phraseF10Inserts the next phrase at the cursor, replacing any selection.
load_phrasesShift+F9Loads .erya-phrases.json.
save_phrasesShift+F10Writes .erya-phrases.json.

What the message row tells you:

  • Captured: “Phrase captured; 3 phrase(s) available”
  • Already there: “That phrase is already in the library” — duplicates are never stored twice
  • Nothing to capture: “There is no text to capture as a phrase”
  • Nothing to insert: “The phrase library is empty; capture a phrase first”
  • Inserted: “Inserted phrase 2/3”
2.4.5

Where phrases are stored

Next to the document you are editing, and only when you ask.

Capturing is not saving

Capturing only puts a phrase in memory. Exit without running “save phrases” and it is gone. Erya never writes that file by itself — deliberately, so it does not leave files in other people's directories.

FileLocation
.erya-phrases.jsonThe directory of the current document. Editing /home/leo/docs/report.txt means /home/leo/docs/.
.erya-macro.json

In effect, phrases and macros follow the folder: one set beside project A, another beside project B. Copy the JSON across to share them.

You can edit the JSON in Erya

The phrase file is simply an array of strings. Open it with Ctrl+O, tidy it with Ctrl+T (see 3.1.7), add a few entries by hand and save; the next load_phrases picks them up.

2.4.6

Recording and running macros

Record a sequence of keys, then replay the whole thing.

  1. Start recording. The message row says “Macro recording started; run the record-macro action again to stop”. From now on every key you press is captured.
  2. Do the thing you want to repeat. Movement, typing, deletion, searching — all fine. The macro management keys themselves are not recorded.
  3. Press again to stop. “Macro recording stopped with 12 key(s)”.
  4. Run it. “Macro executed with 12 key(s)”. Press it repeatedly to repeat the effect.
Action nameKey in ClassicWhat it does
toggle_macro_recordingCtrl+F2Start / stop recording
run_macroCtrl+F3Run the recorded macro
load_macroCtrl+Shift+F2Load .erya-macro.json
save_macroCtrl+Shift+F3Write .erya-macro.json
A whole macro run is one undo step

However much it changed, one Ctrl+Z afterwards returns the document to the state before the run. Experiment freely — if the result is wrong, undo and adjust.

You cannot run while recording

You get “Stop recording before running the macro”. And running before anything has been recorded gives “There is no macro to run”.

2.4.7

Where macros are stored

Same as phrases: the document's directory, saved on request.

  • The file is .erya-macro.json and holds the recorded key sequence.
  • Loading replaces the macro currently in memory and stops recording if it was on.
  • A failed load or save (permissions, broken JSON) reports “Phrase/macro operation failed: …”.
A macro records keys, not actions

What is stored are the physical keys (Ctrl+K), not the meaning “cut the current line”. Replay an old macro under a different key profile and the result can be entirely different. If you share macro files, agree on a profile first.

2.4.8

Bind a key before you can use them

All eight phrase and macro actions are empty in the default profile.

Pressing them and getting nothing is normal

To work in as many terminals as possible, Erya Terminal Safe leaves the eight phrase and macro actions — and five block actions — unbound (see 1.3.9). In F1 help their key column is blank, meaning “the feature is here, but no key calls it”.

Two ways to get them working:

① Switch to Erya Classic

F2 → ← → to Erya Classic → Enter.

All eight get keys immediately (F9, F10, Ctrl+F2…), at the price of changing every other shortcut to the older set.

② Bind only what you need

F2 → E on the key-bindings row → find the action, Enter, type a key → S to save as your own TOML.

Everything else in the default profile stays as it is (see 4.1.4).

2.4.9

Common problems

Six situations around undo, phrases, and macros.

SymptomCause and fix
Undo runs out before you are doneOnly 100 steps, one character each (2.4.2). To discard a lot, close the tab without saving and reopen.
Undo stops working entirelyThe document was reloaded after an external change (2.1.7).
Phrases are gone after a restartThey were never saved. Run “save phrases” after capturing (2.4.5).
Phrases will not load in another directoryThe JSON follows the document's directory. Copy it across (2.4.5).
A macro replays into nonsenseIt records keys, and the profile changed (2.4.7).
None of these keys do anythingThey have no default binding (2.4.8).