2

Let's say you are writing code in one of Emacs window and then want to search for a string that you have copied manually (M-w) some time before.

The problem is, that by default, when you issue C-s, C-y key sequence, Emacs pastes the remaining line under a cursor as a search parameter -- but that's not what I want.

My current workaround is to grab a mouse, click on a Minibuf then yank, but it's too much time consuming.

Version: GNU Emacs 23.3.1 (i686-pc-linux-gnu, GTK+ Version 2.24.10)

3

Just press Return after C-s and then you can paste the search string:

Emacs also has conventional nonincremental search commands, which
require you to type the entire search string before searching begins.

`C-s <RET> STRING <RET>'
     Search for STRING.

`C-r <RET> STRING <RET>'
     Search backward for STRING.

   To start a nonincremental search, first type `C-s <RET>'.  This
enters the minibuffer to read the search string; terminate the string
with <RET>, and then the search takes place.  If the string is not
found, the search command signals an error.
2

If you never really use the 'rest of line' behavior, you can just bind C-y to yank and save yourself the 2 extra keystrokes.

(define-key isearch-mode-map "\C-y" 'isearch-yank-kill)
(define-key isearch-mode-map "\M-y" 'isearch-yank-pop)

I'm not sure if these isearch-yank commands are defined in your version of emacs. If not, just replace them with yank and yank-pop.

0

The default key to paste into an interactive search is M-y.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.