Vim Cheat Sheet
Below is a cheat sheet I reference of the keybindings I’ve set in my neovim dotfiles.
Surrounding text
If you’re using vim-surround
:
ysiw'
: surround inner word with'
cs'"
: change surrounding single quotes with double quotesyss)
: surround line with parenthesesdst
: delete surrounding tagsds)
: delete surrounding parentheses
If you’re using vim-sandwich
:
saiwtem
: surround inner word with<em>
saiw"
: surround the inner word with double quotessd"
: delete surrounding double quotesdt
: delete surrounding tagsr"'
: change surrounding double quote to single quotesrttstrong
: change surrounding tag to<strong>
tagsai3w]
orv3esa]
: put brackets around next 3 words
Here’s a good article about vim-sandwich.
Basic text manipulation
<Leader>/
: comment/uncomment codeciw
: “change inner word”; use instead of “change word”cit
: change text inside tags<C-u>
: upper case word<C-l>
: lower case wordYY
: copy to clipboard<Leader>a =
: align text by =ge
: go back to end of previous word
Navigating file system
<C-n>
: toggle NERDTree to navigate filesystem and open files<C-f>
: fuzzy search files in your open file’s directory
Managing buffers
<Tab>
: go to next buffer
Managing tabs and windows
<C-w>s
: split window horizontally<C-w>v
: split window vertically<C-h>
: switch to window on the left<C-l>
: switch to window on the right<C-k>
: switch to window above<C-j>
: switch to window below
Advanced selections
: -8,-6co.
: copy relative line numbers -8 through -6 to where the cursor is at
Editing modes
<Leader>z
: toggle zenroom (removes all distractions and centers text while editing markdown and text files)