2

I've this org-file:

* Headline a                                                           :tag1:
Text for my Headline a

* Headline b                                                           :tag2:
Text for my Headline b

* Headline c                                                           :tag1:
Text for my Headline c

* Headline d                                                           :tag4:
Text for my Headline d

What is the command to get the following output (show only headline with tag1)?

* Headline a                                                           :tag1:
Text for my Headline a

* Headline c                                                           :tag1:
Text for my Headline c

1 Answer 1

3

You need org-sparse-tree (do C-h f org-sparse-tree for details) which is bound (for me) to C-c /.

Thus C-c / m tag1 will only show headlines matching (that is the force of the m) tag1.

7
  • Using org-sparse-tree you get a buffer in which the headlines matching tag1 are highlighted but the headlines with different tags are not deleted
    – Paolo
    Commented Nov 17, 2022 at 6:22
  • I've noticed that the org-sparse-tree command only works with level 2+ but not with level 1 headlines. The simplest solution I've found (and without writing elisp code) is to demote all headlines 1 and put them under a headline at level 1. At this point the org-spase-tree command hide no matching headlines but this trick still doesn't work if you want to SAVE a buffer containing ONLY the searched and displayed headlines
    – Paolo
    Commented Nov 17, 2022 at 7:31
  • 1
    I think you can save a buffer with the sparse tree using the org export mechanism (export to org...). Commented Nov 17, 2022 at 22:35
  • 1
    C-c C-e C-v O gets me to an "export to org" menu. Have you required ox? Commented Nov 18, 2022 at 17:31
  • 1
    Not that I can see. Commented Nov 21, 2022 at 7:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.