Posts Tagged ‘vi’

Vi – Substitute Word

March 8, 2011 3 comments

Sometimes it is necessary to replace a word with a new word. Vi gives you the option to do this without having to manually go through searching for each occurence of the word individually.

For example, you wish to update a pfile for a database TEST to be used for database DEV. You would use the following command:

$ vi initTEST.ora

(From within VI perform the next steps:)

:1,$ s/TEST/DEV/gc

What the Code Means:


– in vi this allows you to enter a command


– perform this command wherever you see the word to replace


– substitute command


– match word, the /tells Vi the beginning of the word is to follow, the / tells vi that the word has ended.


– text to replace with


– change every occurance on the line not just the first one, this is the global flag


– ask before committing, this allows you to confirm you wish each occurance to be changed as vi picks it up.