The shortcuts you need to survive when you accidentally open Vim. And maybe even like it.
| :q | Quit (if no unsaved changes) |
| :q! | Quit without saving |
| :wq | Save and quit |
| :x | Save and quit (short form) |
| ZZ | Save and quit (even shorter) |
| ZQ | Quit without saving (no colon needed) |
| i | Enter Insert mode (before cursor) |
| a | Enter Insert mode (after cursor) |
| I | Insert at beginning of line |
| A | Insert at end of line |
| o | Open new line below |
| O | Open new line above |
| v | Enter Visual mode (character) |
| V | Enter Visual mode (line) |
| Ctrl+V | Enter Visual Block mode |
| Esc | Return to Normal mode |
| : | Enter Command mode |
| h j k l | Left, Down, Up, Right |
| w | Next word |
| b | Previous word |
| e | End of word |
| 0 | Start of line |
| $ | End of line |
| ^ | First non-blank character |
| gg | Go to first line |
| G | Go to last line |
| :n | Go to line n |
| Ctrl+U | Scroll half page up |
| Ctrl+D | Scroll half page down |
| Ctrl+B | Scroll full page up |
| Ctrl+F | Scroll full page down |
| % | Jump to matching bracket |
| x | Delete character at cursor |
| dd | Delete (cut) line |
| dw | Delete word |
| d$ or D | Delete to end of line |
| yy | Yank (copy) line |
| yw | Yank word |
| p | Paste after cursor |
| P | Paste before cursor |
| u | Undo |
| Ctrl+R | Redo |
| . | Repeat last command |
| rx | Replace character with x |
| cc | Change (replace) entire line |
| cw | Change word |
| c$ or C | Change to end of line |
| ~ | Toggle case |
| >> | Indent line |
| << | Outdent line |
| /pattern | Search forward |
| ?pattern | Search backward |
| n | Next match |
| N | Previous match |
| * | Search word under cursor |
| :s/old/new/g | Replace in line |
| :%s/old/new/g | Replace in file |
| :%s/old/new/gc | Replace with confirmation |
| :noh | Clear search highlighting |
| :w | Save file |
| :w filename | Save as |
| :e filename | Open file |
| :r filename | Insert file contents |
| :bn | Next buffer |
| :bp | Previous buffer |
| :ls | List buffers |
| :sp | Horizontal split |
| :vsp | Vertical split |
| Ctrl+W w | Switch between splits |