Searching and replacing

by Sanju 2009-10-29 14:55:21

Searching and replacing

To search for a word in a document, in regular mode, just type / followed by the chain of characters to be searched for and confirm by hitting the Enter key. Use the n key to go from occurrence to occurrence.

To replace a chain of characters by another on a line, you will find a very powerful command in Vi by using the regular expressions. Its syntax is as follows:

Syntax

:s/chain_to_be_replaced/replacement_chain/


The replacement can be made throughout the entire document with the following syntax:

:%s/chain_to_be_replaced/replacement_chain/



Tagged in:

1130
like
0
dislike
0
mail
flag

You must LOGIN to add comments