This Vim cheat sheet lists the essential commands for the Vim / Vi text editor — switching modes, moving the cursor, editing text and saving or quitting.
Modes
| Key | Action |
|---|---|
| i | Insert mode (before cursor) |
| a | Insert after cursor |
| Esc | Back to normal mode |
| v | Visual select |
| : | Command mode |
Move
| Key | Action |
|---|---|
| h j k l | Left, down, up, right |
| w / b | Next / previous word |
| 0 / $ | Start / end of line |
| gg / G | Top / bottom of file |
| /text | Search for text |
| n / N | Next / previous match |
Edit
| Key | Action |
|---|---|
| x | Delete character |
| dd | Delete line |
| yy | Yank (copy) line |
| p | Paste |
| u | Undo |
| Ctrl+r | Redo |
| r | Replace one character |
| cw | Change word |
Save & quit
| Command | Action |
|---|---|
| :w | Save |
| :q | Quit |
| :wq or :x | Save and quit |
| :q! | Quit without saving |