How to search in Org mode
Table of Contents
Learn a few tips and tricks to help you search keywords like a pro, and easily find information in your Org mode files.
Simple search
For a simple search, type C-c a s
and then all the words you want for your
search (implicit "and"):
portable dvd player
Advanced search
Improve the quality of your search by using a number of advanced search techniques.
Find entries with…
- An exact phrase – To do this, put the phrase in quotes:
"hd ready"
- Any of these words (explicit "or") – To do this, type a regexp (between
curly brackets) using the "alternation" operator:
{sony\|panasonic}
- A phrase or regexp you don't want – To do this, put a minus sign in front:
-accessories
Improve your results by…
- Adding new words you want (or don't want) using
[
(or]
) - Adding new regexps you want (or don't want) using
{
(or}
) - Searching within tagged entries:
biking Italy :errands:
This does not cover inherited tags (use
org-tags-view
for that). - Searching for terms appearing only in the headline (including tags):
*salsa dance
- Searching for terms appearing only in active todo entries:
!book flight
- Searching for exact terms only (no partial match):
:license registered nurse
will not match
licensed
norlicenses
.
You can mix several of the 3 last searches, if you put the signs *
, !
and :
in
that order in front of the first search term.
Use regular expressions to search more precisely
Org keyword search supports the basic regular expressions, where most characters are treated as literals (they match only themselves) with the following exceptions:
-
.
- Matches any single character.
-
[0-9]
- Matches a single character contained within the brackets.
-
[^A-Z]
- Matches a single character not contained within the brackets.
-
^
- Matches the beginning of any line.
-
$
- Matches the end of any line.
-
\(java\|c++\)
- Groups alternatives.
-
*
- Matches the preceding element zero or more times.
-
\{3,5\}
- Matches the preceding element at least
3
and not more than5
times.
It also supports some Perl extensions, such as:
-
\s-
(or[:space:]
) - Matches a space character (to be precise, it matches all characters which are in the whitespace character class, see Emacs Syntax Table).
References
This page is based on Matt Lundin's Advanced searching document.