============================================================================
Using vi to search and replace
This is about as complicated as it gets in vi, since search and replace sytnax is taken from the UNIX sed (stream editor) command.
>> Global search and replace --> :1,$ s/old/new/g
^ ^ ^ ^ ^
In english, this means: | | | | |
| | | | |
From 1 to $ (end of file) | | | |
| | | |
substitute -----------------/ | | |
| | |
occurrences of "old" ----------/ | |
| |
with occurrences of "new" --------/ |
|
globally (i.e., all instances of "old")
========================================================================
Using sed command to replace string in file
#sed -i 's/old/new/g' filename.txt
沒有留言:
張貼留言