I want to do substitution in a partial of a line.
But when I type
:'<,'>s/xx/yy/g, it always do it in the whole line.
How can I tell vim to do it in the exact selection area??
\%V to your search. From
*/\%V* \%V Match inside the Visual area. When Visual mode has already been stopped match in the area that |gv| would reselect. This is a |/zero-width| match. To make sure the whole pattern is inside the Visual area put it at the start and end of the pattern, e.g.: > /\%Vfoo.*bar\%V < Only works for the current buffer.
So you want to do