Turn a search into a repeatable edit
/old<CR>N cgnnew<Esc> .
Example
Normal mode. Cursor on the first o in old old old.
old old oldCursor on line 1, column 1- /old<CR>N Search for old; N returns to the first match
- cgnnew<Esc> First match replaced · new old old
- . Next match replaced · new new old
new new oldCursor on line 1, column 7Details & Vim help
Use cgn to change a search match, then repeat that match change with dot.
Review replacements one at a time while keeping each edit small.
gn always searches forward, regardless of the last search direction, and obeys wrapscan. Stop before wrapping to matches you already reviewed. If replacement text still matches, repetition needs extra care.
Shows cgnnew<Esc> followed by one dot, starting on the first match.
Try it in Vim
- Start at the first character of old old old. Search /old<CR>, then press N to return to the first match.
- Type cgnnew<Esc> to change the selected match.
- Press . to change the next match. To review first, press n to inspect that match, then . to change it or n again to skip it.