Vim Mode
Full vim-style editing in the terminal input.
Overview
A complete vim-mode state machine for the REPL input, supporting INSERT and NORMAL modes with operators, motions, text objects, count prefixes, and dot-repeat.
State Machine
Plain text
Shared from "Claude-Code" on Inkdown
Full vim-style editing in the terminal input.
A complete vim-mode state machine for the REPL input, supporting INSERT and NORMAL modes with operators, motions, text objects, count prefixes, and dot-repeat.
.)Escape switches to NORMAL modeA command state machine:
| Operator | Action |
|---|---|
d | Delete |
c | Change (delete + enter INSERT) |
y | Yank (copy) |
> | Indent |
< | Dedent |
| Motion | Action |
|---|---|
h | Left |
j | Down |
k | Up |
l | Right |
w | Next word |
b | Previous word |
e | End of word |
0 | Start of line |
^ | First non-blank |
$ | End of line |
G | End of buffer |
| Motion | Action |
|---|---|
f<char> | Find char forward |
F<char> | Find char backward |
t<char> | Till char forward |
T<char> | Till char backward |
; | Repeat last find |
, | Reverse last find |
| Object | Inner | Around |
|---|---|---|
| Quotes | i' / i" | a' / a" |
| Parens | i( | a( |
| Brackets | i[ | a[ |
| Braces | i{ | a{ |
| Angle brackets | i< | a< |
Numbers before a command multiply its effect:
resolveMotion() computes cursor positions without side effects:
This pure function approach allows:
types.ts)transitions.ts)Handles state transitions:
| File | Purpose |
|---|---|
src/vim/types.ts | Type definitions |
src/vim/motions.ts | Motion implementations |
src/vim/operators.ts | Operator implementations |
src/vim/textObjects.ts | Text object definitions |
src/vim/transitions.ts | State machine transitions |