All Cheat Sheets
Vim Cheat Sheet
Vim cheat sheet of keyboard shortcuts and commands — modes, motions, text objects, search and replace, macros, registers, buffers, and windows. Works for vi, Vim, and Neovim (nvim).
Modes
Normal mode
EscDefault mode for navigation and commands; Ctrl-[ also worksInsert before / after cursor
i aInsert at line start / end
I AOpen line below / above
o OVisual (char / line / block)
v V Ctrl-vCommand-line mode
:Replace mode
ROverwrite characters as you typeSaving & Quitting
Save
:wSave as
:w newfile.txtSave and quit
:wq or :x or ZZ:x and ZZ only write if there are changesQuit
:qQuit without saving
:q! or ZQQuit all windows
:qa!Save with sudo
:w !sudo tee %Vim only — not supported in NeovimMotions
Left / down / up / right
h j k lNext / prev word start
w bW / B use WORDs (whitespace-separated)End of word
eLine start / first char / end
0 ^ $First / last line
gg GGo to line 42
42G or :42Jump to char in line
f<c> t<c> F<c> T<c>; repeats forward, , repeats backwardMatching bracket
%Paragraph back / forward
{ }Half page down / up
Ctrl-d Ctrl-uScreen top / middle / bottom
H M LCenter cursor line
zzOperators & Text Objects
Operators
d delete c change y yank > indent < unindent = formatCombine operator + motion, e.g. dw, c$, y}Change inner word
ciwDelete a paragraph
dapa = include surrounding whitespace; i = inner onlyChange inside quotes
ci" ci'Delete inside parens / braces
di( di{Also dib / diBChange inside tag
citHTML/XML tag contentsYank to end of line
y$Delete to char
dt)Delete up to (not including) )Operate on whole line
dd cc yy >>Count prefix
3dd 2dw 5jEditing
Delete char
xReplace one char
r<c>Undo / redo
u Ctrl-rRepeat last change
.Paste after / before
p PJoin lines
JToggle case
~guu lowercases a line, gUU uppercases itIncrement / decrement number
Ctrl-a Ctrl-xDelete to end of line
DChange to end of line
CSearch & Replace
Search forward / backward
/pattern ?patternNext / previous match
n NSearch word under cursor
* #Replace in line
:s/old/new/Replace in file
:%s/old/new/gReplace with confirm
:%s/old/new/gcCase-insensitive replace
:%s/old/new/giReplace in range
:10,20s/foo/bar/gWhole word only
:%s/\<foo\>/bar/gClear highlight
:nohRun command on matching lines
:g/TODO/d:v/pattern/d deletes non-matching linesVisual Mode
Select word / paragraph
viw vapReselect last selection
gvIndent selection
> <Swap selection end
oBlock insert on many lines
Ctrl-v j j I text EscInserts text at the same column on each lineAppend to many lines
Ctrl-v j j $ A text EscSort selected lines
:'<,'>sortRegisters & Macros
List registers
:regYank into register a
"ayyPaste from register a
"apSystem clipboard
"+y "+pRequires clipboard support (vim --version | grep clipboard)Last yank (not delete)
"0pRecord macro to q
qq ... qPlay macro
@q then @@ to repeatRun macro 10 times
10@qBuffers, Windows & Tabs
Open file
:e path/to/fileList buffers
:lsNext / prev buffer
:bn :bpSwitch to buffer
:b <num|name>Close buffer
:bdSplit horizontal / vertical
:sp file :vsp fileMove between windows
Ctrl-w h/j/k/lClose / only this window
Ctrl-w q Ctrl-w oEqualize window sizes
Ctrl-w =New tab / next / prev
:tabnew file gt gTMarks & Jumps
Set mark
maLowercase = per file; uppercase (mA) = across filesJump to mark line / exact pos
'a `aJump back / forward
Ctrl-o Ctrl-iLast change position
`. or g;Go to file under cursor
gfPrevious position before jump
``Useful Ex Commands & Settings
Line numbers
:set number :set relativenumberToggle paste mode
:set paste:set nopaste to turn off (not needed in Neovim)Show whitespace
:set listRun shell command
:!lsInsert command output
:r !dateFilter lines through shell
:%!sort | uniqRe-indent whole file
gg=GDelete lines 5–10
:5,10dHelp
:help <topic> e.g. :help text-objectsReload file
:e!Discards unsaved changesNeovim Notes
Launch
nvim file.txtConfig file
~/.config/nvim/init.lua (or init.vim)Vim uses ~/.vimrcLua option example
vim.opt.number = true
vim.keymap.set("n", "<leader>w", ":w<CR>")Health check
:checkhealthBuilt-in terminal
:terminalCtrl-\ Ctrl-n returns to Normal modeKey differences
Built-in LSP and Tree-sitter, sensible defaults (incsearch, hlsearch, autoindent), Lua pluginsMost Vim motions and commands work identicallyKeep the references coming
One email a week: new and trending developer tools, fresh comparisons, and what shipped. Unsubscribe in one click.

