Search and Replace using the vi Editor

Tags:

 If you’re like me then you’re using the unix vi editor like an oxygen tank on mars. But seriously, I’ve always liked the search and replace feature from other graphical based text editors so it’s only fair that we learn how to use vi’s search and replace function. It’s extremely useful and easy once you get the hang of it.

:%s/old_string/new_string/g

Will replace all occurrences of “old_string” with “new_string” in your file. The “%” tells us to execute the search command over the entire file.  The “g” tells us to search AND replace everywhere in the file.  You could also replace a string across a range of lines, for example:

:32,56s/old_string/new_string/g

Will replace “old_string” with “new_string” from line 32 through line 56, pretty handy :)

 

Comments

buy viagra

cialis

cialis online

cialis online

erectile dysfunction

generic viagra

cialis

cialis

cialis ,

cialis

viagra

cialis

cialis online

cheap cialis

buy cialis

buy cialis

cialis

cialis

cialis

cialis

viagra online

viagra online

cialis

buy cialis

cheap viagra

cheap viagra

viagra online

cialis online

discount viagra

cheap cialis

discount viagra

buy viagra

buy cialis

cialis

buy viagra

buy cialis

cheap viagra

buy viagra

generic viagra

generic viagra

buy cialis

generic cialis

cheap cialis

cialis side effects

cheap cialis

generic cialis

generic viagra

generic viagra

generic viagra

cheap cialis

cheap cialis

Post new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
13 + 2 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.