I found substitue in vim has a range parameter:
:[range]s/pattern/sring/[c]/[g]/[e]/[i]/[I]/[p]
But I’m wondering if it would be handy to let the substitution occur only in the visual selection.
Anyone know how to do that?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes, you could do that.
After visual selection, press
:will give you:'<,'>,'<,'>is the[range]part.Then do the substitute like below but note that this will affect the entire line(s):
If you would like to change
footobaronly in the visually selected area (i.e., character-wise or block-wise selection) then you’ll have to use the\%Vatom:The article Search and replace in a visual selection (archive) has much more useful info on the topic.