Take the 2-minute tour ×

How can you have the point at the beginning or end of the search string when accepting a search ?

So say you do C-s "foobar", I would like to have my cursor at the end of the found string when I press RET and at the beginning if I press C-RET.


share|improve this question

1 Answer 1

up vote 2 down vote accepted

Try this:

(defun my-isearch-exit-other-end ()
  "Exit isearch at the other end"
  (when isearch-forward (goto-char isearch-other-end))

(define-key isearch-mode-map (kbd "<C-return>") 'my-isearch-exit-other-end)
share|improve this answer
As seen on emacswiki.org/emacs/ZapToISearch ! :-) –  sanityinc Jul 27 '12 at 19:32

Your Answer


