Operators and Combinations
Operators are the verbs of Vim's editing language. Combined with motions and text objects, they create an almost infinite vocabulary for editing.
Every operator works with every motion and every text object. Learning one new operator or motion multiplies your vocabulary. Learning both multiplies it again.
Complete Operator Reference
| Operator | Action | Doubled |
|---|---|---|
d | Delete | dd — delete line |
c | Change (delete + enter insert) | cc — change line |
y | Yank (copy) | yy — yank line |
> | Indent right | >> — indent current line |
< | Indent left | << — un-indent line |
= | Auto-indent | == — auto-indent line |
~ | Toggle case | — |
g~ | Toggle case (motion) | g~~ — toggle line |
gU | Uppercase | gUU — uppercase line |
gu | Lowercase | guu — lowercase line |
! | Filter through external cmd | — |
gq | Format/wrap text | gqq — format line |
g@ | Apply operatorfunc | — |
Operator + Motion = Action
{operator} {motion}
d$ → delete to end of line
c3w → change 3 words
y{ → yank to previous paragraph
>G → indent from here to end of file
=gg → auto-indent from here to file start
gU$ → uppercase to end of line
gu3j → lowercase 3 lines down
Operator + Text Object = Precise Action
{operator} {i|a} {text-object}
diw → delete inner word
cis → change inner sentence
yap → yank around paragraph
=iB → auto-indent inner brace block
gUiw → uppercase inner word
>ip → indent inner paragraph
!ip sort → sort inner paragraph via external sort command
The d Operator in Detail
d{motion} → delete motion
dd → delete current line
D → delete to end of line (= d$)
x → delete char under cursor (= dl)
X → delete char before cursor (= dh)
diw → delete inner word
daw → delete around word (includes space)
d3w → delete 3 words
d} → delete to end of paragraph
d/pattern → delete to next occurrence of pattern
The c Operator in Detail
c is like d but enters Insert mode afterward.
c{motion} → change motion
cc → change whole line (= S)
C → change to end of line (= c$)
ciw → change inner word (most common)
ci" → change inside quotes
ci( → change inside parentheses
cit → change inside HTML tag
c3w → change 3 words
The y Operator in Detail
y{motion} → yank motion
yy → yank current line
Y → yank to end of line
yiw → yank inner word
yap → yank around paragraph
y/pattern → yank to next pattern match
After yanking, use p to paste after cursor, P to paste before.
The = Auto-Indent Operator
Auto-format indentation using Neovim's current indent rules:
== → auto-indent current line
=G → auto-indent from cursor to end of file
=gg → auto-indent entire file
=aB → auto-indent around brace block (function)
=ip → auto-indent inner paragraph
gg=G → auto-indent ENTIRE FILE (most common use)
gg=G is one of the most useful commands: go to top of file, auto-indent everything. Use after pasting code with broken indentation.
The gU / gu Case Operators
gUiw → uppercase inner word
guiw → lowercase inner word
gU$ → uppercase to end of line
guu → lowercase current line
gUU → uppercase current line
~ → toggle case of character under cursor
g~~ → toggle case of entire line
Indentation Operators
>> → indent current line
<< → un-indent current line
>3j → indent current + next 3 lines
<} → un-indent to end of paragraph
>aB → indent around brace block
In Visual mode, repeat indentation with gv + >:
Vjj> → select 3 lines, indent
gv> → re-select, indent again
Count Multiplier
Prefix any operator+motion with a count:
3dd → delete 3 lines
5>> → indent 5 lines
2yy → yank 2 lines
10j → move down 10 (with operator: d10j = delete 10 lines)
Practical Combination Patterns
| Goal | Command | Explanation |
|---|---|---|
| Remove a function argument | da, or di, | Delete around/inner comma-separated arg |
| Uppercase a variable name | gUiw | Uppercase inner word |
| Replace a string value | ci" + type | Change inside double quotes |
| Swap function body | yiB then p | Yank inner braces, paste elsewhere |
| Format an entire file | gg=G | Top → auto-indent all |
| Remove HTML tag content | cit | Change inner tag |
| Delete to search match | d/foo | Delete up to "foo" |
| Indent a function | =aB | Auto-indent around braces |
The Dot Command — Repeat Last Change
. repeats the entire last change (operator + motion):
ciw "new" → change inner word to "new"
w → move to next word
. → apply the same change ("new") to next word
* → find next occurrence of word under cursor
. → apply last change to it
The dot command is most powerful when combined with / search or * word search.