读书人

vi查询跟替换

发布时间: 2012-11-04 10:42:42 作者: rapoo

vi查询和替换
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

读书人网 >编程

热点推荐