Isearch is one of Emacs’ most useful (and probably most used) features. Getting
in the habit of quickly hitting C-s followed by 2–4 letters will forever
change the way you navigate buffers, and adding it to your repertoire is a
tremendous productivity improvement. What, then, could we possibly improve on
such a phenomenal command?
One of the search actions I find myself doing a lot is to search forward for
other occurrences of the symbol at point. You can do that in Isearch by typing
C-w a few times (which copies the next word at point into the prompt) until
you’ve got the entire symbol, and then you type M-s _ to toggle symbol-search.
However, this is a lot of keys, and it only works if the cursor is at the start
of the symbol. Fortunately, it’s very easy to improve this because the action we
want is already implemented as the isearch-forward-symbol-at-point command.
The result here is that C-s starts Isearch as usual, but if I type C-u C-s
instead it’s going to search for other occurrences of the symbol at point—a
huge improvement over the 6+ keys of our previous option.
Normally, calling Isearch with a prefix would start it in regexp-mode. That’s
not something I’ve ever used, but you should be aware of it before you override
it.
Quickly search for occurrences of the symbol at point
18 Jan 2016, by Artur Malabarba.Isearch is one of Emacs’ most useful (and probably most used) features. Getting in the habit of quickly hitting C-s followed by 2–4 letters will forever change the way you navigate buffers, and adding it to your repertoire is a tremendous productivity improvement. What, then, could we possibly improve on such a phenomenal command?
One of the search actions I find myself doing a lot is to search forward for other occurrences of the symbol at point. You can do that in Isearch by typing C-w a few times (which copies the next word at point into the prompt) until you’ve got the entire symbol, and then you type M-s _ to toggle symbol-search.
However, this is a lot of keys, and it only works if the cursor is at the start of the symbol. Fortunately, it’s very easy to improve this because the action we want is already implemented as the
isearch-forward-symbol-at-point
command.The result here is that C-s starts Isearch as usual, but if I type C-u C-s instead it’s going to search for other occurrences of the symbol at point—a huge improvement over the 6+ keys of our previous option.
Normally, calling Isearch with a prefix would start it in regexp-mode. That’s not something I’ve ever used, but you should be aware of it before you override it.
Tags: convenience, search, init.el, emacs,
New in Emacs 25.1: Round quotes in Help buffers »
« An improvement to Emacs auto-correct
Related Posts
A quick guide to directory-local (or project-specific) variables in convenience
Fill and unfill paragraphs with a single key in convenience
Leave the cursor at start of match after isearch in search
Content © 2019, All rights reserved. Icons under CC3.0.