Minga.Mode.Normal (Minga v0.1.0)

Copy Markdown View Source

Vim Normal mode key handler.

In Normal mode, keys are interpreted as commands — motions, operators, or keys that enter other modes. Digit keys 19 (and 0 after a count has started) accumulate a repeat count stored in the FSM state. The accumulated count is applied by the Minga.Mode dispatcher when an :execute result is returned.

Leader key sequences

Pressing SPC (space) enters leader mode. Subsequent keys are looked up in the Minga.Keymap.Defaults leader trie:

  • Prefix match — continue accumulating (SPC f waits for f, s, …). The editor starts (or resets) a 300 ms which-key timer. When the timer fires the editor shows a popup with the available continuations.
  • Command match — the bound command is executed and leader mode ends.
  • No match — leader mode is cancelled.

The FSM state carries :leader_node (current trie node, nil when not in leader mode) and :leader_keys (list of formatted key strings accumulated so far, for status-bar display).

Supported keys

KeyAction
SPCEnter leader key mode
iTransition to Insert mode
aMove right, transition to Insert
AMove to line end, transition to Insert
IMove to line start, transition to Insert
oInsert line below, transition to Insert
OInsert line above, transition to Insert
hMove left
jMove down
kMove up
lMove right
0Move to line start (when no count) or continue count
19Accumulate count prefix
dEnter operator-pending (delete)
cEnter operator-pending (change)
yEnter operator-pending (yank)
pPaste after cursor
PPaste before cursor
wWord forward
bWord backward
eWord end
$Line end
^First non-blank
GDocument end
EscapeClear count prefix / cancel leader
Ctrl+dHalf-page down
Ctrl+uHalf-page up
Ctrl+fFull page down
Ctrl+bFull page up
Arrow keysMove in corresponding direction

Summary

Functions

Handles a key event in Normal mode.

Functions

handle_key(key, state)

@spec handle_key(Minga.Mode.key(), Minga.Mode.state()) :: Minga.Mode.result()

Handles a key event in Normal mode.

Returns a Minga.Mode.result/0 indicating the FSM transition and any commands to execute.