Repeat the last replacement with the last search pattern
:~
Example
Normal 0 / 2Command-line 1 / 2Normal 2 / 2new old
old oldCursor on line 2, column 1new old
old oldCursor on line 2, column 1new old
new oldCursor on line 2, column 1Repeat the last replacement with the last search pattern.
Vim registers
/Last search register- Characterwise
old
Command entered · ready to apply
Vim registers
/Last search register- Characterwise
old
Reused the last search pattern and replaced the first old on line 2.
Vim registers
/Last search register- Characterwise
old
Before & after
new old
old oldCursor on line 2, column 1Vim registers
/Last search register- Characterwise
old
new old
new oldCursor on line 2, column 1Vim registers
/Last search register- Characterwise
old
Start in Normal mode. A prior :s/old/new/ replaced the first old on line 1, establishing old as the previous pattern and new as the previous replacement. The cursor then moved to line 2; this command reuses that prepared replacement state.
Details & Vim help
Example replayed in Vim
Repeat the previous replacement on the current line using the last search pattern. The bare form drops the previous flags. Add & as the first flag to keep them.