This question already has an answer here:

The command :'<,'>s/search/replace/g will replace in the whole line of the current selection, but what if I want to substitute only inside the current selection, not the whole line?

Update: Found the duplicate.

marked as duplicate by muru Apr 17 '16 at 12:15

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


Use :'<,'>s/\%Vsearch/replace/g

From help substitute:

For the definition of a pattern, see |pattern|.  In Visual block mode, use
|/\%V| in the pattern to have the substitute work in the block only.
Otherwise it works on whole lines anyway.

Not the answer you're looking for? Browse other questions tagged or ask your own question.