Search number of words in vi editor at a time
hi
is it possible that i can search number of words with single command and replace them or delete them in vi editor? or is there any code or something like that? thanks in advance |
I'm not sure I completely understand the question. Can you give a more specific example of what you want to do?
|
here is the example:
i have 3 words, eg cat, dog and hen. I want to search these words in the file animals.txt, I open the file vi animals.txt. and now i want to search these 3 animals using single command or code and delete them in this file. |
Type:
Code:
/cat\|dog\|hen |
thanks!
this works but can you tell me that after selecting how can i delete this, or replace it with in same command. |
To delete the lines containing those patterns:
:global/dog\|cat\|hen/d To substitute those words globally for another word: :global/dog\|cat\|hen/s//duck/g |
All times are GMT -5. The time now is 06:57 AM. |