Skip to main content

Quick Reference

Vim Cheat Sheet

The essential shortcuts every sysadmin and developer needs. No need to memorize the entire manual — just bookmark this page.

10

Categories

80+

Commands

6

Pro Workflows

2

Editing

Entering Insert Mode

iInsert before cursor
IInsert at beginning of line
aInsert after cursor
AInsert at end of line
oOpen new line below cursor
OOpen new line above cursor
EscExit insert mode (return to normal)

Deleting

xDelete character under cursor
XDelete character before cursor
ddDelete (cut) entire line
dwDelete from cursor to start of next word
d$Delete from cursor to end of line
d0Delete from cursor to start of line
DDelete from cursor to end of line (same as d$)

Copy & Paste

yyYank (copy) entire line
ywYank word
y$Yank to end of line
pPaste after cursor
PPaste before cursor

Change & Replace

r{char}Replace single character under cursor
REnter replace mode (overwrite text)
cwChange word (delete & enter insert mode)
ccChange entire line
CChange from cursor to end of line
sSubstitute character (delete & insert)
SSubstitute entire line

Undo, Redo & Repeat

uUndo last change
Ctrl+rRedo last undone change
.Repeat last edit command
5ddDelete 5 lines (prefix any command with a count)
4

Visual 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 selection

Actions on Selection

dDelete selected text
yYank (copy) selected text
>Indent selection right
<Indent selection left
~Toggle case of selection
=Auto-indent selection
5

File 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 vim
6

Buffers & Tabs

Buffers

:lsList all open buffers
:bnGo to next buffer
:bpGo to previous buffer
:bdClose current buffer
:b3Switch to buffer #3

Tabs

:tabnewOpen a new tab
:tabnGo to next tab
:tabpGo to previous tab
:tabcloseClose current tab
gtGo to next tab (normal mode)
gTGo to previous tab (normal mode)
7

Windows & Splits

Creating Splits

:spHorizontal split
:vspVertical split
:sp fileHorizontal split and open file
:vsp fileVertical split and open file

Navigating Splits

Ctrl+w hMove to left split
Ctrl+w jMove to split below
Ctrl+w kMove to split above
Ctrl+w lMove to right split
Ctrl+w wCycle through splits
Ctrl+w qClose current split
Ctrl+w =Equalize split sizes
8

Macros & Registers

Macros

qaStart recording macro into register ‘a’
qStop recording macro
@aPlay macro from register ‘a’
@@Replay last played macro
10@aRun macro ‘a’ ten times

Registers

:regShow all register contents
"ayYank into register ‘a’
"apPaste from register ‘a’
"+yYank into system clipboard
"+pPaste from system clipboard
9

Text 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 word
ci"Change text inside double quotes
ci'Change text inside single quotes
ci(Change text inside parentheses
ci{Change text inside curly braces
ci[Change text inside square brackets
citChange text inside HTML/XML tags

Around Objects

dawDelete around word (includes space)
da"Delete around double quotes (includes quotes)
da(Delete around parentheses (includes parens)
yiwYank inner word
vi{Visually select inside curly braces
vipVisually select inner paragraph
disDelete inner sentence
10

Pro Workflows

Real-world techniques that separate beginners from power users.

#1

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 {}
#2

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)

#3

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
#4

Visual Block Commenting

Comment out multiple lines at once using visual block mode.

Ctrl+v → select lines I#<Esc> → insert # on all
#5

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
#6

Sort & Deduplicate

Clean up lists, configs, and log files without leaving vim.

:%sort → sort all lines :%sort u → sort + dedupe :%sort n → numeric sort
Back to Top

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