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.
Vi and Vim Stack Exchange is a question and answer site for people using the vi and Vim families of text editors. It only takes a minute to sign up.
Sign up to join this communityThe 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.
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.