首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

vi查询跟替换

2012-11-04 
vi查询和替换Vi: Search and ReplaceChange to normal mode with ESC.Search (Wraped around at end of

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

热点排行