Posted By

pflangan on 10/30/11


Tagged

search replace vi


Versions (?)

search and replace vi


 / Published in: Perl
 

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

  1. Vi: Search and Replace
  2. Change to normal mode with <ESC>.
  3. Search (Wraped around at end of file):
  4.  
  5. Search STRING forward : / STRING.
  6. Search STRING backward: ? STRING.
  7.  
  8. Repeat search: n
  9. Repeat search in opposite direction: N (SHIFT-n)
  10.  
  11. Replace: Same as with sed, Replace OLD with NEW:
  12.  
  13. First occurrence on current line: :s/OLD/NEW
  14.  
  15. Globally (all) on current line: :s/OLD/NEW/g
  16. Between two lines #,#: :#,#s/OLD/NEW/g
  17. Every occurrence in file: :%s/OLD/NEW/g

Report this snippet  

You need to login to post a comment.