In A Nice Emacs Trick, I wrote about how you can enter
query-replace-regexp directly from
isearch and use the
isearch search string as the FROM parameter to
query-replace-regexp. It turns out that there's a lot more
isearch goodness available.
Steve Purcell, who I first talked about in Zap Up To A Character, has a nice collection of isearch enhancements. One of these merely drew my attention to functionality that's already there but hardly anyone knows about: you can call
occur directly from
isearch using the search string for the input to
occur by calling
isearch-occur. That's bound to 【Meta+s o】 by default but Purcell binds it to the easier 【Ctrl+o】:
(define-key isearch-mode-map (kbd "C-o") 'isearch-occur)
Another common use case is wanting to end the isearch on the other side of the match. For example, if you are searching forward but want to put point before the match instead of after it you have to do something special to get it there. With a single word for the match,【Meta+b】 does the trick but more complicated matches (multiple words, say) aren't as easy. Purcell provides isearch-exit-other-end to do this and binds it to the very sensible【Ctrl+Return】:
(define-key isearch-mode-map [(control return)] 'isearch-exit-other-end)
I've already added both of these to my
There are a couple of other enhancements in Purcell's init-isearch.el file so be sure to head over and take a look. Perhaps you'll want to add some of the others.