Suppose I have hundreds lines of items:

**** aa
**** bb
**** cc

I try to multiply set tags. I tried to mark them, and use C-c C-q, but it didn't works


As org files are plain text files, we can add tags using a simple approach: query-replace-regexp.

  1. Go to the beginning of the buffer.
  2. Do M-x query-replace-regexp or use the default binding C-M-%.
  3. Enter regexp to match the org headings: ^\*+\s-+.*
  4. To add a tag, you basically append the heading with a space, a : and the tag.
    So the replacement text would be \& :MYTAG. Here \& represents whatever text was matched in the "search" step above.
  5. Now you can review and hit yes only where you want the tag to be appended, or just hit ! if you want to append tags to all the org headings in the buffer.

Here's an example org buffer:

* abc
** def
*** ghi
* jkl
** mno

By implementing the above steps and hit ! in that last step, that would get converted to:

* abc :MYTAG
** def :MYTAG
*** ghi :MYTAG
* jkl :MYTAG
** mno :MYTAG
  • Thank you, it works. By the way, why do you use -+ in regular expression. It is my first time to see it
    – yuxuan
    Jan 14 '16 at 20:41
  • @yuxuan \s- is regexp for whitespace. Check out the \scode section here. Jan 14 '16 at 20:47

org-agenda supports many bulk actions. Do an org-agenda search (C-c a) that matches the entries you're interested in. In the agenda view use m to mark them (or * to mark everything) and the B to select a bulk action. The + action will add a tag to each entry.


If the headlines you want to change tags for are all located in a contiguous region you can highlight them all, and then use the org-change-tag-in-region command.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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