Matching Tags and Properties (Org Mode Compact Guide)

Next: Search View, Previous: Global TODO List, Up: Agenda Views [Contents]

### 10.5 Matching Tags and Properties

If headlines in the agenda files are marked with tags (see Tags), or have properties (see Properties), you can select headlines based on this metadata and collect them into an agenda buffer. The match syntax described here also applies when creating sparse trees with `C-c / m`.

`M-x org-agenda m`

  Produce a list of all headlines that match a given set of tags. The command prompts for a selection criterion, which is a boolean logic expression with tags, like ‘`+work+urgent-withboss`’ or ‘`work|home`’ (see Tags). If you often need a specific search, define a custom command for it (see Agenda Dispatcher).

`M-x org-agenda M`

  Like `m`, but only select headlines that are also TODO items.

A search string can use Boolean operators ‘`&`’ for AND and ‘`|`’ for OR. ‘`&`’ binds more strongly than ‘`|`’. Parentheses are currently not implemented. Each element in the search is either a tag, a regular expression matching tags, or an expression like ‘`PROPERTY OPERATOR VALUE`’ with a comparison operator, accessing a property value. Each element may be preceded by ‘`-`’ to select against it, and ‘`+`’ is syntactic sugar for positive selection. The AND operator ‘`&`’ is optional when ‘`+`’ or ‘`-`’ is present. Here are some examples, using only tags.

‘`+work-boss`’

  Select headlines tagged ‘`work`’, but discard those also tagged ‘`boss`’.

‘`work|laptop`’

  Selects lines tagged ‘`work`’ or ‘`laptop`’.

‘`work|laptop+night`’

  Like before, but require the ‘`laptop`’ lines to be tagged also ‘`night`’.

You may also test for properties at the same time as matching tags, see the manual for more information.

Next: Search View, Previous: Global TODO List, Up: Agenda Views [Contents]