Skip to main content

Operators and Editing Cheatsheet

Visual Quick Guide​

Read each diagram like a ruler — the ^ marks the text the operator acts on.

hello world
^^^^^^
dw delete to the next word (includes the space)

hello world
^^^^^
de delete to the word end (keeps the space)

hello world
^^^^^
diw delete the inner word

"hello world"
^^^^^^^^^^^
ci" change inside the quotes

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

In LazyVim​

LazyVim Context

LazyVim provides powerful additions to standard operators, largely driven by mini.ai, grug-far.nvim, and enhanced commenting setups.

FeatureVanilla NeovimLazyVim
Project Search/ReplaceExternal tools or complex :cdo commandsgrug-far.nvim via <leader>sr (Search and Replace)
CommentingBuilt-in gc (Nvim 0.10+)Enhanced by ts-comments.nvim for proper commenting in multi-language files (e.g., Vue, React, Markdown)
Surround OperationsUsually requires nvim-surroundPre-configured with mini.surround: use sa (add), sd (delete), sr (replace)
Enhanced Text ObjectsDefault vim objects (iw, i(, etc.)Upgraded via mini.ai (e.g., in for next object, il for last)

LazyVim Operator Quick Reference​

  • ``<leader>sr: Opens grug-far in a split for interactive project-wide search and replace.
  • sa{motion}{char}: Add surround (e.g., saiw" to surround word with quotes).
  • sd{char}: Delete surround (e.g., sd" to remove quotes).
  • sr{char}{char}: Replace surround (e.g., sr"' to replace double quotes with single).

What's Next​