Posts Tagged ‘emacs search’

This post started as a quick note (mainly to myself) about a handy sub-feature within emacs find. Since reading through the documentation, I need to mention a few other sub-features too.

As I’ve probably mentioned before, I use both vim and emacs. One great feature of vim is that if you press # or * it searches for the word that your cursor is over. # or * choose a backwards or forwards search respectively.

There is a similar convenience when using emacs search in that if you enter search using C-s then C-w chooses the word you are looking at. I always forget about this feature and my google-fu is never good enough to find it again. Fortunately I recently came across it again when I was looking at the documentation for C-s (isearch-forward) using C-h k C-s.

It turns out that isearch is implemented by a minor mode (logically enough when you think about it) that adds a whole bunch of useful keys, including C-w we mentioned earlier. Other notable features are:

  • C-M-w delete last character in search string
  • M-r toggle regular-expression mode
  • M-e edit search string

And to replace search strings there are:

  • M-% query-replace and
  • C-M-% query-replace-regexp

Read Full Post »