I would like the "search" from search and replace, to be the selected region.

Is there a command doing that already ?

  • 1
    Are you aware of the package iedit? This might be an option if you want to replace all occurrences of the currently selected region in the whole or narrowed buffer.
    – andrej
    Commented Dec 2, 2018 at 9:38
  • @Andrej this looks nice. of course it's already installed on my emacs and I don't know it :)) I think I'll use it, Configuration is powerful, but Convention (as defined by other editors) has a lot of benefit ;)
    – nicolas
    Commented Dec 2, 2018 at 11:48

1 Answer 1


You can do this after selecting text to make it the active region:

  1. M-w, to copy the selected text to the kill-ring, so it can be yanked (pasted).

  2. C-s M-y, to start search (C-s) and yank the last-copied entry of the kill-ring, which is your selected text.

(Just before or after M-w you may want to use C-x C-x to move the cursor to the other end of the selected text, depending on which end it was at to start with. That is, if you want to start your search before that occurrence of the text that was selected, and not after it.)

  • 1
    That is, unfortunately, probably the simplest answer. 30 years ago I did not understand why people used yanked and not paste, or used Stg+x/c/v by default. I know its not you, but I still do not see the point
    – nicolas
    Commented Dec 1, 2018 at 19:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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