Skip to content

Use All Six Modal States

By the end of this chapter, you will have reached Normal, Insert, Replace and all three Visual states, then saved a native change.

Create a fresh practice file with a missing final newline:

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

The status shows Normal. i enters Insert without changing text or moving point. Type Q, then press Escape and wait for Normal. The first line is Qone two; u undoes the insertion. Leaving Insert keeps its insertion point. Normal has no unbound-text fallback: printable keys can be motions, operators or state entry.

At the first grapheme, R enters Replace. Type η•Œ and press Escape. The first line is η•Œne two: one complete grapheme was overwritten. u restores the original. Replace clamps source consumption before a line separator and inserts excess text there. Bracketed paste remains literal insertion. The Insert key separately toggles a view's overwrite preference in Editing or Insert.

Press v for Visual Character, V for Visual Line, then Ctrl-V for Visual Block. Watch the state label change each time. Escape returns to Normal without editing. Character selection includes the destination grapheme; Line selects complete logical lines; Block counts logical graphemes rather than screen cells. Tabs and wide graphemes each count as one block column, and short rows clamp.

In Visual states, supported motions extend point while mark retains the other endpoint. o exchanges the endpoints. y copies, d kills and c kills then enters Insert. Character/Line > and < indent/outdent lines. Block retention joins rows with LF for ordinary linear paste; it does not invent padded columns.

Return to the first line with gg, then type cw, followed by X. A complete native word change enters Insert before X is accepted. Press Escape after the text has appeared. The buffer is now Xtwo followed by the unchanged last line. d, c, y, > and < compose with supported motions or iw, aw, ip, ap objects. For example, 2d3w composes one count of six; it does not make six separate undo steps. Ctrl-G clears an incomplete composition.

Ctrl-X Ctrl-S saves the file. Ctrl-X Ctrl-C exits the modal profile. At the shell, cat modal.txt should show Xtwo and last, with no final newline.

The editing reference lists the finite operator and state scope.

Previous: Modal Interaction | Part | User Guide | Next: User Guide