Quick Reference
Vim Cheat Sheet
The essential shortcuts every sysadmin and developer needs. No need to memorize the entire manual — just bookmark this page.
Categories
Commands
Pro Workflows
Editing
Entering Insert Mode
iInsert before cursorIInsert at beginning of lineaInsert after cursorAInsert at end of lineoOpen new line below cursorOOpen new line above cursorEscExit insert mode (return to normal)Deleting
xDelete character under cursorXDelete character before cursorddDelete (cut) entire linedwDelete from cursor to start of next wordd$Delete from cursor to end of lined0Delete from cursor to start of lineDDelete from cursor to end of line (same as d$)Copy & Paste
yyYank (copy) entire lineywYank wordy$Yank to end of linepPaste after cursorPPaste before cursorChange & Replace
r{char}Replace single character under cursorREnter replace mode (overwrite text)cwChange word (delete & enter insert mode)ccChange entire lineCChange from cursor to end of linesSubstitute character (delete & insert)SSubstitute entire lineUndo, Redo & Repeat
uUndo last changeCtrl+rRedo last undone change.Repeat last edit command5ddDelete 5 lines (prefix any command with a count)Search & Replace
Searching
/patternSearch forward for pattern?patternSearch backward for patternnJump to next matchNJump to previous match:nohClear search highlightingReplacing
:s/old/newReplace first occurrence on current line:s/old/new/gReplace all occurrences on current line:%s/old/new/gReplace all occurrences in entire file:%s/old/new/gcReplace all with confirmation prompt:%s/old/new/giReplace all, case insensitiveVisual Mode
Selecting
vStart visual mode (character selection)VStart visual line mode (full-line selection)Ctrl+vStart visual block mode (column selection)gvRe-select last visual selectionActions on Selection
dDelete selected textyYank (copy) selected text>Indent selection right<Indent selection left~Toggle case of selection=Auto-indent selectionFile Operations
Save & Quit
:wSave (write) file:w fileSave as different filename:qQuit (fails if unsaved changes):q!Force quit without saving:wqSave and quit:xSave and quit (only writes if modified)ZZSame as :x (save & quit)ZQSame as :q! (quit without saving)File Management
:e fileOpen file for editing:e!Revert to last saved version:r fileInsert contents of file below cursor:r !cmdInsert output of shell command:!cmdRun shell command without leaving vimBuffers & Tabs
Buffers
:lsList all open buffers:bnGo to next buffer:bpGo to previous buffer:bdClose current buffer:b3Switch to buffer #3Tabs
:tabnewOpen a new tab:tabnGo to next tab:tabpGo to previous tab:tabcloseClose current tabgtGo to next tab (normal mode)gTGo to previous tab (normal mode)Windows & Splits
Creating Splits
:spHorizontal split:vspVertical split:sp fileHorizontal split and open file:vsp fileVertical split and open fileNavigating Splits
Ctrl+w hMove to left splitCtrl+w jMove to split belowCtrl+w kMove to split aboveCtrl+w lMove to right splitCtrl+w wCycle through splitsCtrl+w qClose current splitCtrl+w =Equalize split sizesMacros & Registers
Macros
qaStart recording macro into register ‘a’qStop recording macro@aPlay macro from register ‘a’@@Replay last played macro10@aRun macro ‘a’ ten timesRegisters
:regShow all register contents"ayYank into register ‘a’"apPaste from register ‘a’"+yYank into system clipboard"+pPaste from system clipboardText Objects
Combine with operators like d (delete), c (change), y (yank), or v (select). Use i for “inner” (contents only) or a for “around” (include delimiters).
Inner Objects
ciwChange inner wordci"Change text inside double quotesci'Change text inside single quotesci(Change text inside parenthesesci{Change text inside curly bracesci[Change text inside square bracketscitChange text inside HTML/XML tagsAround Objects
dawDelete around word (includes space)da"Delete around double quotes (includes quotes)da(Delete around parentheses (includes parens)yiwYank inner wordvi{Visually select inside curly bracesvipVisually select inner paragraphdisDelete inner sentencePro Workflows
Real-world techniques that separate beginners from power users.
Change Inside Delimiters
Instantly replace text inside quotes, brackets, or parens. Works from anywhere on the line.
ci" → change inside ""
ci( → change inside ()
ci{ → change inside {}
Auto-Indent Entire File
Fix messy indentation across an entire config file or script in one command.
gg=G
gg (top) → = (indent) → G (to bottom)
The Dot Command
Make one edit, then repeat it everywhere with a single keystroke.
ciw new_text <Esc>
n → find next match
. → repeat the change
Visual Block Commenting
Comment out multiple lines at once using visual block mode.
Ctrl+v → select lines
I#<Esc> → insert # on all
Record & Replay Macros
Automate repetitive edits by recording a sequence and replaying it.
qa → start recording
(do your edits)
q → stop recording
50@a → replay 50 times
Sort & Deduplicate
Clean up lists, configs, and log files without leaving vim.
:%sort → sort all lines
:%sort u → sort + dedupe
:%sort n → numeric sort
Need IT support beyond Vim?
Bullium Consulting provides strategic IT partnerships for growing businesses. From infrastructure to security, we handle the tech so you can handle your business.
Schedule a Consultation