Reputation: 1726
Given the text: ab
Why does this command :s/a\|b//
only substitute the text a
?
But when you search with pattern a\|b
, both the text a
and b
are matched.
Upvotes: 1
Views: 68
Reputation: 965
You should append /g , to substitute each matched pattern, or it will substitute the first matched pattern.
:s/a\|b//g
You can find the following information through :help substitute
[g] Replace all occurrences in the line. Without this argument, replacement occurs only for the first occurrence in each line.
Upvotes: 5