Tip5: Find and Replace by Hand

January 12, 2021 ยท View on GitHub

Search 'target' and replace all the 'target'

:%s/target/replacemnet/g

But one by one?

/target

search document for next match.

*

execute a search for the word under the cursor at that moment.

*nn

cycle through all matches, taking us back to where we started.

cw

delete to the end of the word and drop us into Insert mode.

Example

tip5

Tip4 Tip6

Contents

  1. 1Search 'target' and replace all the 'target'
  2. 2But one by one?
  3. 3/target
  4. 4*nn
  5. 5cw