2013年7月17日 星期三

Vi: Search and Replace

Reference:
http://www.felixgers.de/teaching/emacs/vi_search_replace.html

Change to normal mode with <ESC>.
Search (Wrapped around at end of file):
  Search STRING forward :   / STRING.
  Search STRING backward:   ? STRING.

  Repeat search:   n
  Repeat search in opposite direction:   (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 

沒有留言:

張貼留言