[CLUE-Tech] vi search/replace question
marcus hall
marcus at tuells.org
Fri Apr 23 13:03:57 MDT 2004
On Thu, Apr 22, 2004 at 10:54:50AM -0600, Dave Price wrote:
> 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 about:
:g/^#/d
Just like you would do in good old ed. This breaks down into ":", which
tells vi to execute an ex (non-graphical interface to vi) command, "g/^#/"
which says to apply the command to lines that match /^#/ globally (over the
entire file), and finally "d", which is the delete command.
And I'm a regular emacs user..
Marcus Hall
marcus at tuells.org
More information about the clue-tech
mailing list