Normal Mode (6) – Replace Phrase
In Normal mode, you can search for a phrase and replace it with a new phrase using the command below.
:[search area]s/[search phrase]/[replace phrase]/option
Search area
%
: you can search and replace a phrase in the entire document
n
: you can search and replace a phrase under line n
Option
g
: you can replace all phrases in the selected search area. If you select the entire document, option g is the default setting.
c
: you can make confirmations for replacement one by one
Examples
Replace the first A with B in line 3 (no confirmation)
:3s/A/B
Replace all A with B in line 3 (no confirmation)
:3s/A/B/g
Replace all A with B in line 3 (one-by-one confirmation)
:3s/A/B/gc
Replace all A with B in the entire document (no confirmation)
:%s/A/B/g
Replace all A with B in the entire document (one-by-one confirmation)
:%s/A/B/gc