Posted By

ragnarokkrr on 07/04/11


Tagged

search replace vi


Versions (?)

VI - Search and Replace


 / Published in: Bash
 

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

  1. Change to normal mode with <ESC>.
  2.  
  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.  
  17. Between two lines #,#: :#,#s/OLD/NEW/g
  18.  
  19. Every occurrence in file: :%s/OLD/NEW/g

Report this snippet  

You need to login to post a comment.