Before doing substitution, I usually type /foo to search the pattern first.
Vim automatically highlight all strings match the pattern.
Then I figure out how to write the substitution command :%s/foo/bar/g.
When the pattern is complex, it’s much harder to write the substitution command than the search command.
If I can do substitution only on highlighted strings. It becomes easy.
For example:
Question: Translate Part of a Line
I can figure out the search pattern: /\[\[\(http\)\@!.\{-}\]\]
But I cannot figure out the substitution command easily.
You can replace the previously searched pattern if you use an empty string as the search pattern in the substitute command:
After
/footype:%s//bar/gin normal mode to replace “foo” by “bar”.