Operators and Editing Cheatsheet
Operators (Verbs)
d delete (into register)
c change (delete + enter insert)
y yank (copy)
> indent right
< indent left
= auto-indent
gU uppercase
gu lowercase
g~ toggle case
! filter through external command
Important Operator Shortcuts
dd delete line
cc change line (= S)
yy yank line
>> indent line
<< un-indent line
== auto-indent line
D delete to end of line (= d$)
C change to end of line (= c$)
Y yank to end of line
Text Objects
iw aw inner/around word
iW aW inner/around WORD
is as inner/around sentence
ip ap inner/around paragraph
i" a" inner/around double quotes
i' a' inner/around single quotes
i( a( inner/around parentheses (also ib ab)
i[ a[ inner/around square brackets
i{ a{ inner/around braces (also iB aB)
i< a< inner/around angle brackets
it at inner/around HTML tag
Treesitter text objects:
if af inner/around function
ic ac inner/around class
ia aa inner/around argument
il al inner/around loop
ii ai inner/around conditional
Common Combinations
diw delete inner word
ciw change inner word
yiw yank inner word
ci" change inside quotes
ca( change around parentheses
dip delete inner paragraph
yap yank around paragraph
=iB auto-indent inner braces
gUiw uppercase inner word
daf delete entire function (treesitter)
Modes Summary
Normal mode: Default. All keys are commands.
Insert mode: Type text. Enter with: i a o O I A s S
Visual mode: Select. v (char), V (line), Ctrl+v (block)
Command mode: : commands. Enter with : from Normal.
Terminal mode: Shell. Exit with: Ctrl+\ Ctrl+n
Registers
" unnamed (default)
0 last yank (survives subsequent deletes)
1-9 delete history
a-z named (manual)
+ system clipboard
_ black hole (no storage)
% current filename
. last inserted text
: last command
/ last search pattern
Usage:
"ayiw yank into register 'a'
"ap paste from register 'a'
"+y yank to system clipboard
"0p paste from yank register (safe after deletes)
Ctrl+r a (Insert mode) insert register 'a'
Search and Replace
/pattern search forward
:%s/old/new/g global replace in file
:%s/old/new/gc global replace with confirm
:'<,'>s/old/new/g replace in visual selection
:g/pattern/d delete all matching lines
:g/pattern/p print all matching lines
Flags: g=global i=case-insensitive c=confirm
Undo / Redo
u undo
Ctrl+r redo
U undo all changes on current line
:earlier 5m go to state 5 minutes ago
:later 30s go forward 30 seconds
Dot Repeat
. repeat last change
n. find next match, apply last change
Macros
q{reg} start recording to register
q stop recording
@{reg} replay macro
@@ replay last macro
5@a replay 'a' 5 times
:%normal @a run macro on every line
Essential Command Mode Commands
:w save
:q quit
:wq save and quit
:q! force quit
:e file open file
:vs file vertical split
:sp file horizontal split
:bn :bp next/prev buffer
:bd close buffer
:%bdelete close all buffers
:noh clear search highlight
:set opt set option
:help topic open help