Vim Normal mode key handler.
In Normal mode, keys are interpreted as commands — motions, operators, or
keys that enter other modes. Digit keys 1–9 (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 fwaits forf,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
| Key | Action |
|---|---|
SPC | Enter leader key mode |
i | Transition to Insert mode |
a | Move right, transition to Insert |
A | Move to line end, transition to Insert |
I | Move to line start, transition to Insert |
o | Insert line below, transition to Insert |
O | Insert line above, transition to Insert |
h | Move left |
j | Move down |
k | Move up |
l | Move right |
0 | Move to line start (when no count) or continue count |
1–9 | Accumulate count prefix |
d | Enter operator-pending (delete) |
c | Enter operator-pending (change) |
y | Enter operator-pending (yank) |
p | Paste after cursor |
P | Paste before cursor |
w | Word forward |
b | Word backward |
e | Word end |
$ | Line end |
^ | First non-blank |
G | Document end |
Escape | Clear count prefix / cancel leader |
Ctrl+d | Half-page down |
Ctrl+u | Half-page up |
Ctrl+f | Full page down |
Ctrl+b | Full page up |
| Arrow keys | Move in corresponding direction |
Summary
Functions
Handles a key event in Normal mode.
Functions
@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.