[CLUE-Tech] vi search/replace question

Dave Price dp_kinaole at yahoo.com
Thu Apr 22 10:54:50 MDT 2004


Hello,

This one comes up too often for me, and I don't know if there is an easy
way to do it just with vi/vim:

Is there a way to delete entire lines globbally from a file when part
of the line matches a pattern?

For example, I want to remove all the lines the start with a particular
character, perhaps #, (so the regex to find the lines would be ^# ...

How can I tell vi to replace the regex and the rest of the line with
'nothing'?

I know I could do this easily by piping the file out to grep -i, but
lets just say I don't have a good grep available under this OS.... Or I
just want to learn to do this entirely in vi.

Of course, if it can be done with one command in (horrors) emacs, I
would be interested in learning how.

Thanks, and

aloha (textually),
dave




More information about the clue-tech mailing list