You have no idea how powerful isearch is!
https://emacsredux.com/blog/2025/03/18/you-have-no-idea-how-powerful-isearch-is/Open linkView original on lemmy.mlSyndicated from the fediverse. Read and engage on the original instance.
View original on lemmy.ml
https://emacsredux.com/blog/2025/03/18/you-have-no-idea-how-powerful-isearch-is/Open linkView original on lemmy.ml
3 replies
isearchis probably one of the most widely known Emacs commands. Every Emacs user knows that they can run it usingC-s(to search forward) andC-rto search backwards. Everyone also knows they can keep pressingC-sandC-rto go over the list of matches in the current buffer. Even at this point that’s a very useful command. But that doesn’t even scratch the surface of what isearch can do!After you’ve started
isearchyou can actually do a lot more than pressingC-sandC-r:DELto cancel last input item from end of search string.RETto exit, leaving point at location found.LFD(C-j) to match end of line.M-s M-<to go to the first match,M-s M->to go to the last match. (super handy)C-wto yank next word or character in buffer onto the end of the search string, and search for it. (very handy)C-M-dto delete character from end of search string.C-M-yto yank char from buffer onto end of search string and search for it.C-M-zto yank from point until the next instance of a specified character onto end of search string and search for it.M-s C-eto yank rest of line onto end of search string and search for it.C-yto yank the last string of killed text.M-yto replace string just yanked into search prompt with string killed before it.C-qto quote control character to search for it.C-x 8 RETto add a character to search by Unicode name, with completion.C-gwhile searching or when search has failed cancels input back to what has been found successfully.C-gwhen search is successful aborts and moves point to starting point.You can also toggle some settings when
isearchis active:M-s cto toggle search case-sensitivity.M-s ito toggle search in invisible text.M-s rto toggle regular-expression mode.M-s wto toggle word mode.M-s _to toggle symbol mode.M-s 'to toggle character folding.M-s SPCto toggle whitespace matching.In incremental searches, a space or spaces normally matches any whitespace defined by the variable
search-whitespace-regexp; see also the variablesisearch-lax-whitespaceandisearch-regexp-lax-whitespace.Type
M-s eto edit the search string in the minibuffer. That one is super useful! Also supported is a search ring of the previous 16 search strings:M-nto search for the next item in the search ring.M-pto search for the previous item in the search ring.C-M-ito complete the search string using the search ring.Last, but not least - you can directly search for the symbol/thing at point:
M-s .to search for the symbol at point. (useful in the context of programming languages)M-s M-.to search for the thing (e.g. word or symbol) at point.One of the most useful parts of that is the fact that a region is a thing. So you can mark a region (e.g. with
expand-regionormark-*) andM-s M-.to immediately search for other instances of that text. Powerful stuff!Tip: You don’t really have to remember all those keybindings - just remember you can press
C-h bto show them. (after you’ve startedisearch) Most of the above text is coming straight from the docstring ofisearch.It’s funny that I’ve been using Emacs for almost 20 years, I use
isearchnumerous times every day and I still often forget about much of its functionality. There’s more toisearch, though. Did you know it’s widely customizable as well? If you check its options withM-x customize-group isearchyou’ll see there are over 30 (!!!) options there! Admittedly, I never used any of them, but you’ve got quite a lot of opportunities to tweak the behavior of isearch if you want to. Here’s an example of a customization some of you might find useful:I hope you learned something useful today! Keep searching (the Emacs docs)!`___`
seriously though
Wait until you rebind C-s and C-r to the regexp versions of isearch. 💪😀