Friday, October 5, 2012

Getting to grips with …. vi

I'm almost ashamed to admit that I'm still somewhat of a newbie when it comes to vi, but, like Manual, I come from Barcelona I learn.

I have blogged about vi before, and have also reviewed the Wikipedia page ( hasn't everyone ? ). There's also this: -


However, I'm grateful to one of my colleagues for showing me how one may search/replace in vi rather than, as I used to do, cheating and starting a GUI editor ( kate, gedit, tedit etc. ). This is especially useful where X11 is not available to one.

So, I wanted to replace the phrase AppServer_1 with AppServer in a response file: -

$ vi installWAS85.rsp

:1,$ s/AppServer_1/AppServer/g

This is broken down as follows: -

: Bring up the vi command line
1,$ Start at the first column, continue until the end of the line
s/ Start search
AppServer_1 Word to search for
/ Separator
AppServer Word to replace with
/g End search

Simples :-)

No comments:

Post a Comment