Vim Delete and Change — d, c, x, r, s Operators
Master Vim's delete and change operators: d, dd, dw, d$, c, cc, cw, x, r, s. Learn the operator+motion pattern that makes Vim editing so powerful.
Editing
Detailed Explanation
The Operator+Motion Pattern
Vim's editing power comes from composing operators with motions:
{operator}{motion}
Delete Operator (d)
| Command | Action |
|---|---|
x |
Delete character under cursor |
X |
Delete character before cursor |
dw |
Delete from cursor to next word start |
de |
Delete from cursor to end of word |
db |
Delete backward to start of word |
dd |
Delete entire line |
d$ or D |
Delete to end of line |
d0 |
Delete to beginning of line |
dG |
Delete from current line to end of file |
dgg |
Delete from current line to beginning of file |
d} |
Delete to next paragraph |
Change Operator (c)
Change works exactly like delete, but enters Insert mode after:
| Command | Action |
|---|---|
cw |
Change to end of word |
cc or S |
Change entire line |
c$ or C |
Change to end of line |
c0 |
Change to beginning of line |
cb |
Change backward to start of word |
Single Character Operations
| Key | Action |
|---|---|
r{char} |
Replace character under cursor with char |
R |
Enter Replace mode (overwrite as you type) |
s |
Substitute character (delete + enter Insert) |
Counts
Add a count before any command to repeat it:
3dd— Delete 3 lines5x— Delete 5 characters2cw— Change 2 words
Use Case
You are editing code or text and need to delete, replace, or change specific portions efficiently using Vim's composable operator+motion system.