1

I can use C-x n s (org-narrow-to-subtree) to narrow the content to the current subtree, which is great. After doing that, I want to search a keyword in the current narrowed subtree(instead of the whole file). I tried opening org-agenda, and use the search functionality(s) in it. But it didn't work as expected. Org Mode searched the whole file for my keyword.

So my question is, how to only search in the current narrowed subtree?

2
  • 1
    Are you talking about some kind of special org-specific search feature? Because the normal isearch (C-s) or occur (M-s o) etc will work just fine in a narrowed buffer.
    – phils
    Commented Dec 3, 2020 at 5:39
  • @phils Yes, I'm talking about the search feature in org-mode. C-s isn't enough for me because I want to search the narrowed buffer but only show the result as an org heading list, C-s cannot do this.
    – Searene
    Commented Dec 3, 2020 at 6:05

1 Answer 1

1

Assuming that C-c a brings up the agenda dispatcher, you can restrict the agenda search by saying C-c a < s in the narrowed buffer. The dispatcher documentation says:

‘<’ Restrict an agenda command to the current buffer. If narrowing is in effect restrict to the narrowed part of the buffer. After pressing ‘<’, you still need to press the character selecting the command.

1
  • Thanks, it worked just as expected! Except that when the search result is shown, I was kicked out of the narrowed buffer. It would be better if I can remain in the narrowed buffer. That said, it's good enough since going into the narrowed buffer again isn't a hard thing.
    – Searene
    Commented Dec 4, 2020 at 3:33

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.