How do I do a Find and Replace within a selection in vi?
How do I do a Find and Replace within a selection in vi ?
Share
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.
If your selection is a across one or more lines, this can be done by selecting the text in visual mode (I assume that’s what you’re doing), then press
:to start typing a command, you’ll see something like this appear in the command line:That means that the command will apply to the selection. Then type
s/search/replace/and hit enter. (Add agafter the third slash if you want to replace all matches, and acif you want a confirmation for every replace)