개발자세상/Shell 관련
VI 문자열 대치
headiron
2009. 1. 23. 15:26
누가 정리해 놓은건지는 몰라도 정말 잘 정리 되어 있는것 같다.
Replace: Same as with sed, Replace OLD with NEW:
Vi: Search and Replace
Change to normal mode with <ESC>.
Search (Wraped around at end of file):
Search STRING forward : / STRING. Search STRING backward: ? STRING. Repeat search: n Repeat search in opposite direction: N (SHIFT-n)
Replace: Same as with sed, Replace OLD with NEW:
First occurrence on current line: :s/OLD/NEW Globally (all) on current line: :s/OLD/NEW/g Between two lines #,#: :#,#s/OLD/NEW/g Every occurrence in file: :%s/OLD/NEW/g