# Vim
## Core
- i = insert mode
- Esc = normal mode
- : command mode
### Saving, quitting...
- `:wq` - save and quit
- `:w` - save file but don't exit
- `:q!` - quit and throw away unsaved changes
- ZZ
- save and exit immediately
## Functions
- Undo
- `u`
### Navigate
- Go to end of file
- `GA`
- Go to start of file
- `gg`
- Page Down/UP
- `Ctrl-b` (back)
- `Ctrl-f` (forward)
### Select, delete
- visual mode - see highlighted selection
- `V`
- Select all
- `ggVG` (gg: go to start of file, V - enter visual mode, G - select from current position to end of file)
- delete
- `d`
- Delete all lines
- To clear all the lines of a file: `:%d` (Select All - % Delete - d
### Cut, Copy, Paste
- [editor - How to make Vim paste from (and copy to) the system's clipboard? - Stack Overflow](https://stackoverflow.com/questions/11489428/how-to-make-vim-paste-from-and-copy-to-the-systems-clipboard)
- Copy ("yank") the selected files
- `y`
- paste (from vim clipboard, not system clipboard
- `p`
- Paste from system clipboard
- `"*p`
### Search
- `/` (search forward) then ENTER
- `?` (search backward) then ENTER
- n searches for next occurrence, N searches for previous