Change the current or next match
Example
Normal 0 / 4Operator pending 1 / 4Insert 2 / 4Insert 3 / 4Normal 4 / 4old blue oldCursor on line 1, column 1old blue oldCursor on line 1, column 1 blue oldInsertion point on line 1, column 1new blue oldInsertion point on line 1, column 4new blue oldCursor on line 1, column 3Replace a forward match of the last search pattern.
Vim registers
"Unnamed register- Characterwise
saved -Small delete register- Characterwise
prior
Prepared search
- Pattern
old
Begin a change operator; retain the prepared registers.
Vim registers
"Unnamed register- Characterwise
saved -Small delete register- Characterwise
prior
Prepared search
- Pattern
old
Change the current search match, store old in the unnamed and small-delete registers, and enter Insert mode.
Vim registers
"Unnamed register Changed- Characterwise
old -Small delete register Changed- Characterwise
old
Prepared search
- Pattern
old
Type the concrete replacement while preserving both registers.
Vim registers
"Unnamed register- Characterwise
old -Small delete register- Characterwise
old
Prepared search
- Pattern
old
Finish the replacement; the unnamed and small-delete registers still contain old.
Vim registers
"Unnamed register- Characterwise
old -Small delete register- Characterwise
old
Prepared search
- Pattern
old
Before & after
old blue oldCursor on line 1, column 1Vim registers
"Unnamed register- Characterwise
saved -Small delete register- Characterwise
prior
Prepared search
- Pattern
old
new blue oldCursor on line 1, column 3Vim registers
"Unnamed register Changed- Characterwise
old -Small delete register Changed- Characterwise
old
Prepared search
- Pattern
old
ILLUSTRATION. The last search pattern is old; the cursor is on its first match. Replacement text is new. Prepared characterwise registers contain saved in the unnamed register and prior in the small-delete (-) register. Changing this single-line match replaces both with old; typing the replacement preserves them.
Details & Vim help
Replace a forward match of the last search pattern.
c applies to gn, which selects the match under the cursor or searches forward. Type a replacement and Esc; dot can then repeat that match change. After a forward search, n visits the next match for review; it does not skip that match for a following dot. Advance to another match before repeating if you want to skip it. gn always searches forward, while n follows the last search direction; wrapscan controls wrapping.