Skip to content

Repeat and Record Changes

By the end of this chapter, you will have repeated a complete change at a fresh target and recorded a reusable semantic macro.

Start a fresh process for this exercise:

printf 'one two\nlast' > repeat.txt
cargo run --locked -p rur-editor --bin rur-terminal-proof -- --profile modal repeat.txt

Type cwX, wait for X to appear, then Escape. Move to the second line with j0 and press .. The buffer is Xtwo on the first line and X on the second. Dot repeats the completed Change and its Insert text at the current target, as one new undoable edit. u undoes that repeat while retaining the first change. In nonmodal Editing, choose repeat-last-change through Alt-x. In Normal, a new positive count substitutes the retained count under the original command policy.

Repeat keeps complete corrected input, including local Backspace/Delete, rather than a suffix or a stream of old keys. Motion and state boundaries seal text capture. If the latest committed change cannot be retained completely, repeat becomes unavailable; it never falls back to an older change. Rejection or cancellation of repeat leaves the completed original change intact.

Save repeat.txt. Through Alt-x, choose create-named-buffer, enter macro-demo, and press Enter. Press i. Ctrl-X ( starts recording; type Q; Ctrl-X ) finishes. Ctrl-X e replays the complete last macro, leaving QQ. F4 also finishes a recording or calls the last definition.

Ctrl-X Ctrl-K n names an independent copy. Enter append-q. Later use Alt-x, call-named-keyboard-macro, Enter, append-q, Enter to insert another Q. The buffer is QQQ. Replacing an existing name requires the explicit yes confirmation. Recorded definitions and their names live only in this process.

Macros retain semantic commands and complete text/count/slot arguments. They resolve current command and target admission on each step. Recorder controls, nested implementation calls and prompt answers are not recorded. A rejection, new prompt, close/exit or uncertain external result stops replay before the next step. Earlier edits and completed Saves remain true; undo uses ordinary command history. Ctrl-G stops replay or discards only a working recording, preserving the last complete definition. The status reports the completed prefix and stop.

Save macro-demo to macro-demo.txt, then leave through Ctrl-X Ctrl-C. Resolve remaining dirty decisions. At the shell, cat macro-demo.txt should show QQQ. For configuration, limits and optional clipboard/pointer support, continue with the editing reference and Configure Terminal Commands.

Previous: Move and Retain Text | Part | User Guide | Next: Change Two Files Together