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??
How to do substitution in the selected part of a line instead of the whole line?
substitute;visual mode
Add \%V to your search. From :h /\%V:                        */\%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 :'<,'>s/\%Vxx/yy/g