Activities

October 2009
M T W T F S S
« Aug   Nov »
 1234
567891011
12131415161718
19202122232425
262728293031  

VI command for find and replace

Hello,

This is most suitable commands which help us to replace the string with our occurrence. This is the same feature of “Find and replace ” in windows 🙂

open the file to be edit
$ vi strings.txt
a. then press “Esc”
:%s/find-string/replace-string/g
Then press enter
then press Esc key and “ZZ” key to save the file. You may use Esc + :wq

some tweaks are listed below,
1. First occurrence on current line: :s/OLD/NEW
2, Every occurrence in file: :%s/OLD/NEW/g

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>