Command Mode

Files and directories

:e filename open file filename
:w save current file
:pwd show working directory
:cd change working directory for all windows
:lcd change working directory only for current window
:lcd %:p:h change working directory to directory of full path of current file

Buffers

:new create new window with new empty buffer
:ls list all buffers
:bn switch to next buffer
:bp switch to previous buffer
:b2 switch to buffer 2
:b exa switch to buffer with filename that matches exa (use tab for completion if unsure)
ctrl-^ toggle between current and last buffer
:bd delete current buffer
:bd! discard changes and delete buffer

Windows

:vsp split window vertically

Tabs

:tabe filename edit filename in new tab

Substitution

:.,+#s/xyz/abc/g Starting with current line through # additional lines,
substitute “abc” for “xyz” globally
(each occurrence is changed rather than just the first)
:.,+#s/^/ / Starting with current line through # additional lines,
add space to beginning of line
:.,-#s/^/ / Starting with current line through # previous lines,
add space to beginning of line

Normal Mode

Text

Copy & Paste

y copy text
yy copy current line
y#y copy # of lines starting with current line and moving down
yw copy current word
y#w copy # of words starting with current word and moving right
p paste line/word after current line/word
P paste line/word before current line/word

Visual

v enter visual mode

Windows

ctrl-w v split window vertically
ctrl-w s split window horizontally
ctrl-w l or ctrl-w right move to window to the right
ctrl-w h or ctrl-w left move to window to the left
ctrl-w j or ctrl-w down move to window to the bottom
ctrl-w k or ctrl-w up move to window to the top
ctrl-w w move to other window
ctrl-w > increase width of window
ctrl-w < decrease width of window
ctrl-w + increase height of window
ctrl-w - decrease height of window
ctrl-w = balance window dimensions

Insert mode

esc go to normal mode
ctrl-[ go to normal mode (useful when esc isn’t passed to vim)

Extensions

NERDTree

C change working directory to selected (requires NERDTreeChDirMode=2)

https://www.freecodecamp.org/news/vim-editor-modes-explained/
https://www.fprintf.net/vimCheatSheet.html
https://vim.fandom.com/wiki/Project_browsing_using_find