[CLUE-Tech] vi search/replace question

Chris Greene r0x0rman at yahoo.com
Fri Apr 23 07:49:38 MDT 2004


:g/search string/d 

 :g/^#/d to delete all lines that start with # 

-----Original Message-----
From: clue-tech-admin at clue.denver.co.us
[mailto:clue-tech-admin at clue.denver.co.us] On Behalf Of Dave Price
Sent: Thursday, April 22, 2004 10:55 AM
To: clue-tech at clue.denver.co.us
Subject: [CLUE-Tech] vi search/replace question

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

_______________________________________________
CLUE-Tech mailing list
Post messages to: CLUE-Tech at clue.denver.co.us Unsubscribe or manage your
options: http://clue.denver.co.us/mailman/listinfo/clue-tech




More information about the clue-tech mailing list