str[bits]

July 21, 2005

How to search and replace in vi?

Filed under: Linux

I got a friend here in work asked me “How to search and replace in vi”?

To search:

/ STRING
(Above should be known almost to all Linux/Unix users :) )

To replace:

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

Comments »

The URI to TrackBack this entry is: http://str.blogsome.com/2005/07/21/how-to-search-and-replace-in-vi/trackback/

No comments yet.

RSS feed for comments on this post.

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>























Get free blog up and running in minutes with Blogsome | Theme designs available here