help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Emacs equivalent of the ":g" command in vi


From: Deniz Dogan
Subject: Re: Emacs equivalent of the ":g" command in vi
Date: Fri, 22 Jul 2011 12:46:41 +0200
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0) Gecko/20110624 Thunderbird/5.0

On 2011-07-22 12:45, Deniz Dogan wrote:
On 2011-07-22 12:02, C K Kashyap wrote:
> which could be as simple as in vi/vim.)
I think he want to delete lines matching a regexp, so C-k is not what he
wants here.

`query-replace-regexp' can be used with a regexp like this:

^.*\(your_regexp\).*$

and you replace with nothing (empty prompt).

--


replace-regexp is indeed closer to what I am looking for. However, I'd
like the result to not leave blank lines.

Regards,
Kashyap

First, either move to the start of where you want to search OR make an
active region (select) the parts where you want it to take effect. M-<
goes to the beginning of the buffer and C-x h marks the whole buffer, FYI.

Now, M-x delete-matching-lines RET your_regexp RET


You may also want to know about:

Global Bindings Starting With M-s:
key             binding
---             -------

M-s h           Prefix Command
M-s o           occur
M-s w           isearch-forward-word

M-s h f         hi-lock-find-patterns
M-s h l         highlight-lines-matching-regexp
M-s h p         highlight-phrase
M-s h r         highlight-regexp
M-s h u         unhighlight-regexp
M-s h w         hi-lock-write-interactive-patterns

As you can see, e.g. M-s h r can be very useful at times.

Deniz



reply via email to

[Prev in Thread] Current Thread [Next in Thread]