Modes

rtdvi is modal. Every keystroke is interpreted by the current mode's handler.

Mode summary

ModeEnter withLeave withWhat it does
Normal(default; <Esc> from anywhere)(stays in normal)Motions, operators, ex command entry
Inserti a I A o O (or c)<Esc>Types characters into the buffer
Visualv<Esc> / operatorCharacter-wise selection
Visual-lineV<Esc> / operatorLine-wise selection
Visual-block<C-v><Esc> / operatorRectangular selection
Command:<Esc> / <CR>Ex command line
Search/ ?<Esc> / <CR>Forward/backward search

The current mode is shown as a coloured badge on the active window's statusline.

How dispatch works

The Normal and three Visual modes all route through the keymap trie (see src/keymap/trie.rs). Each mode owns a key→action mapping in Editor.keymap. The mode's handle_key pushes the typed key onto the pending sequence, asks the trie to resolve, and either dispatches the matched action, waits for more keys, or rejects.

Count digits are intercepted by try_accumulate_count in src/mode/mod.rs before keys reach the trie.

Insert mode bypasses the trie for typed characters — every printable key inserts at the cursor. A few special keys (<Esc>, <Enter>, <Backspace>, <Tab>) are handled directly.

Command and Search modes own their own line editors (the : prompt and / prompt at the bottom of the screen).

Pending state in Normal mode

Three pieces of state are tracked between keystrokes:

Any rejection (Resolve::None) clears both pending_keys and the counts so the user can start over cleanly.

Mode transitions

Every mode change emits a ModeChanged event on the editor's event bus, so future listeners (a status-aware plugin layer) can react.

Esc semantics

Looking for a key binding?