Emacs: Searching your notes

C-s (isearch-forward) and C-r (isearch-backward) are two of the most useful Emacs keyboard shortcuts you’ll ever learn. To search forward interactively, type C-s (isearch-forward) and the first few characters of your search. Repeat C-s (isearch-forward) as necessary, or type in more characters to jump to the first instance that matches all those characters. Use these shortcuts to not only search your Org file, but also to quickly jump to sections. For example, I often search for headlines by typing C-s (isearch-forward) * start-of-my-headline. Org searches collapsed sections, so you don’t need to open everything before searching.

To search using Org’s outline structure, use C-c / r (org-sparse-tree, regexp), which will show only entries matching a regular expression. For more information about regular expressions, read the Emacs info manual entry on Regexps. Here are a few examples:

To find Search for
All entries containing "cat" cat
All entries that contain "cat" as a word by itself (example: "cat," but not "catch") \<cat\>
All entries that contain 2006, 2007, or 2008 200[678]
  • Thanks for the \ tip. I’ve always gotten away with the generic \b for word boundaries, as in \bcat\b, but these angle brackets will come in handy. I’ve been using emacs almost every day for 12 years and I still find something new and useful on almost every one of those days.

    Thanks for this recent series of emacs posts.

    • \b works just as well. =)

      Yeah, Emacs is like that. I’m looking forward to always learning more and more about it. Remember that learning curve graph of Emacs?

      You’re welcome!

  • That should be “the backslash leftangle and backslash rightangle tip” :-)

  • Dima Fomin

    thank you for post serie! 10 years later it’s still useful :)