Tuesday, August 18, 2009

Search and Replace in VIM

Syntax

:s/search/replace/
:[range]s/search/replace/

Examples

# Search & replace in current line
:s/entry/interview

# Search & replace in lines 8 to 10
:8,10 s/search/replace/

# Global search & replace
:%s/entry/interview/g

# Global search & replace with prompt
:%s/entry/interview/gc

More awesome search and replace tips at http://linux.com/learn/tutorials/8255-vim-tips-the-basics-of-search-and-replace

No comments:

Blog Archive