Usig vi as my editor, i want to search for all occurences a text
string and in those lines where the text string is found i want to
replace another different string in that line with a new string.
Does anybody know how to do this in vi???
Does anybody know how to do this in vi???
> Does anybody know how to do this in vi???
--
Linux solution for data processing and document management.
You will find helpful answers to this and other editor,Quote:> Using vi as my editor, i want to search for all occurences a text
> string and in those lines where the text string is found i want to
> replace another different string in that line with a new string.
> Does anybody know how to do this in vi???
Open the file using vi
type a : to put you in ex mode -- you will see a : at
the very left-bottom of the screen.
type
g/search_string/s/old_string/new_string/g
g - in every line
/search_string/ - search for this string
s - substitute
/old_string/ - string to replace, may be the same or
different from search string
/new_string/ - replacement string, new text
g - do this for all occurrances of old_string in line
> Does anybody know how to do this in vi???
:g/string1/s/string2/new_string/
isn't simple and nice ?
> > Using vi as my editor, i want to search for all occurences a text
> > string and in those lines where the text string is found i want to
> > replace another different string in that line with a new string.
> > Does anybody know how to do this in vi???
> You will find helpful answers to this and other editor,
> vi related questions in comp.editors. There you will also find
> Frequently Asked Questions (FAQs) that address similar issues.
> Open the file using vi
> type a : to put you in ex mode -- you will see a : at
> the very left-bottom of the screen.
> type
> g/search_string/s/old_string/new_string/g
> g - in every line
> /search_string/ - search for this string
> s - substitute
> /old_string/ - string to replace, may be the same or
> different from search string
> /new_string/ - replacement string, new text
> g - do this for all occurrances of old_string in line
But wrong, and top posted.Quote:> :s/old_string/new_string/g
> isn't simple and nice ?
/bb
1. newbie question on search and replace using vi editor
I am trying to replace the word error
with MyError in the vi editor
so the word error appears
like this monerror
or stuerror
wold I replace doing this
s/\<error>/MyError/g
with g being for Global.
I tried doing this and the document
was not updated from what I could see.
Thanks
Kevin
--
remove the words REMOVETHIS to reply me
00
<
__/ Kevin D.
2. Tekram's SCSI Card Linux Supported
3. vi search/replace question...
4. Sound setup?
5. RH 5 & IPX
6. Global search and replace using vi -c?
7. Setting MAC address at boot
8. global search+replace a newline with J in vi?
9. vi search/replace: Want >1 line context
10. How to search and replace a decimal in vi?
11. Vi search and replace don't work
12. Searching/replacing / with vi