Saturday, August 30, 2008

Search and Replace in vi editor

Replace the word at the beginning of the sentence. Press ecs in vi editor and type
:%s/^step/more/g
This command replace the sentence starting with 'step' with the word 'more'.
'g' option is used to replace everything (globle search). Other wise it replaces the first sentence.

:%s/end$/first/g
This command replaces the word of end at the end of sentence with first.

Serch by word
:%s/\/new/g

if you want to replace " character with someother word or charecter use
:%s/\"/word/g
or :%s/["]/word/g

No comments: