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 modeEscDefault mode for navigation and commands; Ctrl-[ also works
Insert before / after cursori a
Insert at line start / endI A
Open line below / aboveo O
Visual (char / line / block)v V Ctrl-v
Command-line mode:
Replace modeROverwrite characters as you type

Saving & Quitting

Save:w
Save as:w newfile.txt
Save and quit:wq or :x or ZZ:x and ZZ only write if there are changes
Quit:q
Quit without saving:q! or ZQ
Quit all windows:qa!
Save with sudo:w !sudo tee %Vim only — not supported in Neovim

Motions

Left / down / up / righth j k l
Next / prev word startw bW / B use WORDs (whitespace-separated)
End of worde
Line start / first char / end0 ^ $
First / last linegg G
Go to line 4242G or :42
Jump to char in linef<c> t<c> F<c> T<c>; repeats forward, , repeats backward
Matching bracket%
Paragraph back / forward{ }
Half page down / upCtrl-d Ctrl-u
Screen top / middle / bottomH M L
Center cursor linezz

Operators & Text Objects

Operatorsd delete c change y yank > indent < unindent = formatCombine operator + motion, e.g. dw, c$, y}
Change inner wordciw
Delete a paragraphdapa = include surrounding whitespace; i = inner only
Change inside quotesci" ci'
Delete inside parens / bracesdi( di{Also dib / diB
Change inside tagcitHTML/XML tag contents
Yank to end of liney$
Delete to chardt)Delete up to (not including) )
Operate on whole linedd cc yy >>
Count prefix3dd 2dw 5j

Editing

Delete charx
Replace one charr<c>
Undo / redou Ctrl-r
Repeat last change.
Paste after / beforep P
Join linesJ
Toggle case~guu lowercases a line, gUU uppercases it
Increment / decrement numberCtrl-a Ctrl-x
Delete to end of lineD
Change to end of lineC

Search & Replace

Search forward / backward/pattern ?pattern
Next / previous matchn N
Search word under cursor* #
Replace in line:s/old/new/
Replace in file:%s/old/new/g
Replace with confirm:%s/old/new/gc
Case-insensitive replace:%s/old/new/gi
Replace in range:10,20s/foo/bar/g
Whole word only:%s/\<foo\>/bar/g
Clear highlight:noh
Run command on matching lines:g/TODO/d:v/pattern/d deletes non-matching lines

Visual Mode

Select word / paragraphviw vap
Reselect last selectiongv
Indent selection> <
Swap selection endo
Block insert on many linesCtrl-v j j I text EscInserts text at the same column on each line
Append to many linesCtrl-v j j $ A text Esc
Sort selected lines:'<,'>sort

Registers & Macros

List registers:reg
Yank into register a"ayy
Paste from register a"ap
System clipboard"+y "+pRequires clipboard support (vim --version | grep clipboard)
Last yank (not delete)"0p
Record macro to qqq ... q
Play macro@q then @@ to repeat
Run macro 10 times10@q

Buffers, Windows & Tabs

Open file:e path/to/file
List buffers:ls
Next / prev buffer:bn :bp
Switch to buffer:b <num|name>
Close buffer:bd
Split horizontal / vertical:sp file :vsp file
Move between windowsCtrl-w h/j/k/l
Close / only this windowCtrl-w q Ctrl-w o
Equalize window sizesCtrl-w =
New tab / next / prev:tabnew file gt gT

Marks & Jumps

Set markmaLowercase = per file; uppercase (mA) = across files
Jump to mark line / exact pos'a `a
Jump back / forwardCtrl-o Ctrl-i
Last change position`. or g;
Go to file under cursorgf
Previous position before jump``

Useful Ex Commands & Settings

Line numbers:set number :set relativenumber
Toggle paste mode:set paste:set nopaste to turn off (not needed in Neovim)
Show whitespace:set list
Run shell command:!ls
Insert command output:r !date
Filter lines through shell:%!sort | uniq
Re-indent whole filegg=G
Delete lines 5–10:5,10d
Help:help <topic> e.g. :help text-objects
Reload file:e!Discards unsaved changes

Neovim Notes

Launchnvim file.txt
Config file~/.config/nvim/init.lua (or init.vim)Vim uses ~/.vimrc
Lua option examplevim.opt.number = true vim.keymap.set("n", "<leader>w", ":w<CR>")
Health check:checkhealth
Built-in terminal:terminalCtrl-\ Ctrl-n returns to Normal mode
Key differencesBuilt-in LSP and Tree-sitter, sensible defaults (incsearch, hlsearch, autoindent), Lua pluginsMost Vim motions and commands work identically

Keep the references coming

One email a week: new and trending developer tools, fresh comparisons, and what shipped. Unsubscribe in one click.