53
Chapter 6: Tags
59
6 Tags
An excellent way to implement labels and contexts for cross-correlating information is to
assign tags to headlines. Org mode has extensive support for tags.
Every headline can contain a list of tags; they occur at the end of the headline. Tags are
normal words containing letters, numbers, ‘_’, and ‘@’. Tags must be preceded and followed
by a single colon, e.g., ‘:work:’. Several tags can be specified, as in ‘:work:urgent:’. Tags
will by default be in bold face with the same color as the headline. You may specify special
faces for specific tags using the option org-tag-faces, in much the same way as you can
for TODO keywords (seeSection5.2.6[FacesforTODOkeywords],page50).
6.1 Tag inheritance
Tags make use of the hierarchical structure of outline trees. If a heading has a certain tag,
all subheadings will inherit the tag as well. For example, in the list
* Meeting with the French group
:work:
** Summary by Frank
:boss:notes:
*** TODO Prepare slides for him
:action:
the final heading will have the tags ‘:work:’, ‘:boss:’, ‘:notes:’, and ‘:action:’ even
though the final heading is not explicitly marked with those tags. You can also set tags
that all entries in a file should inherit just as if these tags were defined in a hypothetical
level zero that surrounds the entire file. Use a line like this
1
:
#+FILETAGS: :Peter:Boss:Secret:
To limit tag inheritance to specific tags, use org-tags-exclude-from-inheritance. To
turn it off entirely, use org-use-tag-inheritance.
When a headline matches during a tags search while tag inheritance is turned on, all
the sublevels in the same tree will (for a simple match form) match as well
2
. The list of
matches may then become very long. If you only want to see the first tags match in a
subtree, configure org-tags-match-list-sublevels (not recommended).
Tag inheritance is relevant when the agenda search tries to match a tag, either in the
tags or tags-todo agenda types. In other agenda types, org-use-tag-inheritance has
no effect. Still, you may want to have your tags correctly set in the agenda, so that tag
filtering works fine, with inherited tags. Set org-agenda-use-tag-inheritance to control
this: the default value includes all agenda types, but setting this to nil can really speed
up agenda generation.
6.2 Setting tags
Tags can simply be typed into the buffer at the end of a headline. After a colon, M-TAB
offers completion on tags. There is also a special command for inserting tags:
C-c C-q
org-set-tags-command
Enter new tags for the current headline. Org mode will either offer completion
or a special single-key interface for setting tags, see below. After pressing RET,
1
As with all these in-buffer settings, pressing C-c C-c activates any changes in the line.
2
This is only true if the search does not involve more complex tests including properties (seeSection7.3
[Property searches], page 66).