To replace word in vi, the below steps can be used(replace OLD with NEW). Please make sure you are in command(normal) mode:
- to replace first occurrence of OLD to NEW on current line
- :s/OLD/NEW
- to replace all occurrence of OLD to NEW on current line
- :s/OLD/NEW/g
- to replace all occurrence of OLD to NEW between two line numbers (# are the line numbers)
- :#,#s/OLD/NEW/g
- to replace every occurrence of OLD to NEW on current file
- :%s/OLD/NEW/g
No comments:
Post a Comment