Search, change, inspect, repeat
The technique
Each . changes the next match. Stop before the archive: one more would change it too.
Keys in this lesson
- cgn
- Change the next search match; . changes the one after.
- n
- Next match.
- .
- Repeat the last change.
Before this lesson: Search reuse; repeatable changes.
More about this lesson
Keep exceptions while repeating a change to selected matches.
Search, make a change, use n to inspect the next match, then dot only where the same edit belongs. cgn includes selecting a search match in the change itself; dot can then seek and change the next match. Stop before exceptions. Neither a shorter route nor a successful dot proves that every match should change.
Example
If two current lines and an archive say pending, update the two current lines and leave the archive. Check each destination rather than blindly repeating across the file.
Use Reset to try again.