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

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

RE: killing the result of isearch


From: Drew Adams
Subject: RE: killing the result of isearch
Date: Mon, 6 Nov 2017 21:34:29 -0800 (PST)

> I must be missing something big...

No, you're not.

> I have an isearch that highlights a string, and I just 
> want to delete that string.
> 
> In other editors I'd just hit delete on that selection,
> but that won't work in emacs...

Not in vanilla Emacs, no; it won't work.

If you use Isearch+ then you can hit `C-M-RET' to delete the
search hit.  (The current search hit is not the "selection",
BTW, in the sense of being the Emacs region.)

[If you prefer that the key for this be, say, the `<delete>'
key, then just bind command `isearchp-act-on-demand' to
`(kbd "<delete>")' in `isearch-mode-map'.]

With Isearch+, `C-M-RET' performs an action on the current
search hit.  By default, the action is to replace it with
some replacement text.  And by default that replacement
text is empty (""), i.e., the search hit is deleted.

The value of option `isearchp-on-demand-action-function'
is the function that acts on the current search hit, which
it is passed when you hit `C-M-RET', along with the buffer
start and end positions of the search hit.

After applying the action, search moves to the next hit in
the same search direction, so just repeating `C-M-RET'
carries out the action on subsequent hits.

With a prefix argument, `C-M-RET'  prompts for the
replacement text, which is used thereafter until you again
use a prefix arg.  (Again, no prefix arg means empty
replacement text, i.e., deletion.)

Since you can use a prefix arg at any time, you can
provide different replacements for different search hits
corresponding to the same search pattern.

[To use a prefix arg within Isearch, you must set
`isearch-allow-prefix' to non-`nil'.]

There's more you can do with it.  See here:

https://www.emacswiki.org/emacs/IsearchPlus#isearchp-act-on-demand




reply via email to

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