Standard text editors map most keystrokes directly to characters on screen. Vim is a modal editor where keystrokes have different meanings depending on the current mode. This design allows efficient keyboard-driven editing without modifier keys, but requires learning mode switching.
Vim uses modal editing — different keystrokes do different things depending on the current mode. The main modes are Normal (for commands), Insert (for typing), and Visual (for selection).
- Normal mode: Default mode. Keystrokes are commands (move, delete, yank, etc.). Press
ESCto return here from other modes. - Insert mode: Type characters literally. Press
ifrom Normal to enter,ESCto exit. - Visual mode: Select text for operations. Enter with
v(character-wise),V(line-wise), or<C-v>(block-wise).
Key mappings:
| Key | Action |
|---|---|
i | Enter Insert mode before cursor |
a | Enter Insert mode after cursor |
ESC | Return to Normal mode |
- Vim starts in Normal mode by default
- Mode switching is explicit — no hold-to-edit like Ctrl in conventional editors
- Visual mode has three variants: character, line, and block
:进入 Ex 命令行 mode (also considered a mode)
- Accidental key presses in Normal mode can cause unintended edits (e.g.,
iin the middle of a word inserts before it, not split it — usesorainstead) - Caps Lock matters:
iis insert,Iis different command :help modeshows current mode help
- Survival Commands — Five commands that work in Normal mode
- Text Objects — Selection commands that require Visual mode
- Visual Selection — Modes for selecting text blocks
- Macros — Recording in Normal mode