Essential Vim Commands
Changing Modes
A- Enter INSERT mode at end of linea- Enter INSERT mode at end of characterI- Enter INSERT mode at start of linei- Enter INSERT mode at start of charactero- Enter INSERT mode on new line belowO- Enter INSERT mode on new line abovev- Enter VISUAL modeCtrl-v- Enter VISUAL BLOCK modeShft-v- Enter VISUAL-LINE mode and highlight current line
Editing Text
y- Yank/copy current selectionp- Paste content at end of characterP- Paste content at beginning of characteru- Undo commandCtrl-r- Redo commandx- Delete current character- In VISUAL mode:
u- Convert all characters to lowercaseU- Convert all characters to uppercase~- Switch captialization of all characters
dw- Delete word from cursor to end of worddiw- Delete whole word with cursor on any characterb- Go to beggining or worde- Go to end of wordgg- Go to first lineShft-g- Go to last line
/<expression>- Search current document for<expression>:%s/<expression>/<replace>/<option>- Replaces all occurances of<expression>with<replace><option> = c- Require confirmation before replacing
Managing Code
gcc- Comment current line (fromvim-commentary)gc- Comment current selection (fromvim-commentary)gd- Go to definition (fromCoc)gy- Go to type definition (fromCoc)gi- Go to implementation (fromCoc)gr- Go to reference (fromCoc)- Opens window showing references/occurances of the object
Ctrl-o- Move backwards in the jumplist (useful for exiting go to commands)Ctrl-i- Move forwards in the jumplist
zo- Open current foldzc- Close current foldzR- Open all foldszM- Close all folds
Managing Files, Windows, and Tabs
F2- Open tree file explorer (or:NERDTree)\ff- Open Telescope file finder (or:Telescope file_finder)\fg- Open Telescope live grep (or:Telescope live_grep)
Ctrl-w- Enter window adjustment modes- Horizontal splitv- Vertical splitq- Close active windoww- Go to next windowj/k/h/l- Move to window in direction
:sp- Splits horizontally:vsp- Splits vertically:so <file>- Sources the file
Wrapping Braces
Use of nvim-surround Highlight text in VISUAL mode and use S{ replacing { by the character you want to surround with.