code.devpill.dk
174 commands across 9 sections

The Vim Cheatsheet

A modern, opinionated reference of the commands that actually earn their place in your muscle memory — from :q to q@a.

The Basics

The handful of commands you actually need on day one — entering, exiting, saving, and undoing.

Exiting Vim

The eternal question — finally answered.

:qClose file
:qaClose all files
:wSave
:wqSave and close file
:xSave and close file
ZZSave and quit
ZQQuit without checking changes
Esc / <C-[>Exit insert mode
<C-C>Exit insert mode and abort current command

Word Navigation

Move around without ever touching the arrow keys.

h / j / k / lLeft / down / up / right
<C-U> / <C-D>Half-page up / down
<C-B> / <C-F>Page up / down
b / wPrevious / next word
ge / ePrevious / next end of word
0Start of line
^Start of line (after whitespace)
$End of line

Document Navigation

Jump across the file with surgical precision.

f{char}Jump forward to a character
F{char}Jump backward to a character
t{char}Jump until (before) a character
ggFirst line
GLast line
:{n}Go to line {n}
{n}GGo to line {n}
{n}jGo down {n} lines
{n}kGo up {n} lines
%Jump to matching bracket

Editing

Insert, append, replace — the core editing verbs.

aAppend after cursor
AAppend at end of line
iInsert before cursor
IInsert at start of line
oOpen new line below
OOpen new line above
sDelete character and insert
SDelete line and insert
CChange to end of line
rReplace one character
REnter Replace mode
uUndo
<C-R>Redo
.Repeat last change

Visual Mode

Select first, act second.

vEnter visual mode
VEnter visual line mode
<C-V>Enter visual block mode
d / xDelete selection
sReplace selection
yYank selection (copy)
gvReselect last visual selection
oMove cursor to other end of selection

Clipboard

Cut, copy, paste — Vim style.

xDelete character
ddDelete line (cut)
yyYank line (copy)
pPaste after cursor
PPaste before cursor
"*p / "+pPaste from system clipboard
"*y / "+yYank to system clipboard
:regList all registers

Operators

Operators act on a range of text defined by a motion. Combine them to express edits like sentences.

Operators list

See :help operator

dDelete
yYank (copy)
cChange (delete then insert)
>Indent right
<Indent left
=Auto-indent
g~Swap case
gU / guUppercase / lowercase
!Filter through external program

Examples

Compose operators with motions and counts.

ddDelete the current line
dwDelete to next word
dbDelete to beginning of word
2ddDelete 2 lines
d$Delete to end of line
dipDelete inside paragraph
ci"Change inside double quotes
yi(Yank inside parentheses
>apIndent a paragraph

Text Objects

Operate on logical chunks — words, sentences, blocks, tags — with i (inside) or a (around).

Text objects

See :help text-objects

pParagraph
wWord
sSentence
[ ( { <A bracket / brace block
' " `A quoted string
bA ( ) block
BA { } block
tAn XML / HTML tag block

Examples

Pair an operator with a text object.

vipSelect inner paragraph
yipYank inner paragraph
yapYank paragraph (with newline)
dipDelete inner paragraph
cipChange inner paragraph
ditDelete inside HTML / XML tag
ca{Change around braces

Search & Replace

Find, jump, and rewrite text — from a single occurrence to every match in the file.

Searching

Incremental search and navigation.

/patternSearch forward
?patternSearch backward
n / NNext / previous match
*Search word under cursor (forward)
#Search word under cursor (backward)
:nohClear search highlight
gdGo to local definition

Substitution

Replace patterns across lines, ranges, or the whole file.

:s/foo/bar/Replace first match on line
:s/foo/bar/gReplace all on current line
:%s/foo/bar/gReplace all in file
:%s/foo/bar/gcReplace all in file, confirm each
:'<,'>s/foo/bar/gReplace within visual selection
:g/pattern/dDelete lines matching pattern
:v/pattern/dDelete lines NOT matching pattern

Macros & Registers

Record sequences of commands and replay them. Store yanked text in named registers.

Macros

Record once, replay anywhere.

q{a-z}Start recording into register
qStop recording
@{a-z}Replay macro from register
@@Replay last macro
{n}@{a-z}Replay macro n times
:regList register contents

Registers

Named clipboards for text and commands.

"{a-z}yYank into named register
"{a-z}pPaste from named register
"0Last yanked text
"+ / "*System clipboard
"_Black hole — discard text
"%Current file name
":Last Ex command

Marks & Jumps

Bookmark positions in files and zip between them.

Marks

Set them with m, jump with ` or '.

m{a-z}Set mark in current buffer
m{A-Z}Set global mark across files
`{mark}Jump to exact mark position
'{mark}Jump to start of mark's line
`.Jump to last change
``Jump back to position before last jump
:marksList all marks

Jump list

Vim remembers where you've been.

<C-O>Jump to older position
<C-I>Jump to newer position
:jumpsShow jump list
g;Go to older change
g,Go to newer change

Windows, Buffers & Tabs

Split your screen, juggle buffers, and organize workspaces with tabs.

Windows

Split panes within the same Vim session.

:sp / :splitHorizontal split
:vsp / :vsplitVertical split
<C-W>h/j/k/lMove between windows
<C-W>wCycle windows
<C-W>qClose window
<C-W>oClose all other windows
<C-W>=Equalize sizes
<C-W>_Maximize height
<C-W>|Maximize width

Buffers

Files Vim has loaded into memory.

:ls / :buffersList buffers
:b {name|n}Switch to buffer
:bn / :bpNext / previous buffer
:bdDelete (close) buffer
:e {file}Edit file in current window

Tabs

Workspaces holding window layouts.

:tabnew {file}Open file in new tab
gt / gTNext / previous tab
{n}gtGo to tab n
:tabcloseClose tab
:tabonlyClose all other tabs

Folding

Collapse regions of text so you can focus on what matters.

Folding commands

See :help folding

zf{motion}Create fold over motion
zo / zcOpen / close fold
zaToggle fold
zROpen all folds
zMClose all folds
zdDelete fold
zj / zkNext / previous fold

Power Tips

A handful of small commands that punch well above their weight.

Productivity boosters

Memorize these and never look back.

.Repeat the last change
;Repeat last f/F/t/T motion
,Reverse last f/F/t/T motion
<C-A>Increment number under cursor
<C-X>Decrement number under cursor
JJoin line below into current line
gJJoin without inserting a space
~Toggle case of character
gq{motion}Reformat text
<C-G>Show file info

Command line

Ex commands that pay rent.

:help {topic}Open help for topic
:e .Open file explorer (netrw)
:!{cmd}Run shell command
:r {file}Insert contents of file
:r !{cmd}Insert output of shell command
:set nuShow line numbers
:set rnuShow relative line numbers
:sortSort lines
:earlier 5mTime-travel undo by 5 minutes