Skip to content

add AND/OR and hash tag search modes#718

Open
aleksejkrueger wants to merge 3 commits intoobsidian-nvim:mainfrom
aleksejkrueger:feat/tag-search-modes
Open

add AND/OR and hash tag search modes#718
aleksejkrueger wants to merge 3 commits intoobsidian-nvim:mainfrom
aleksejkrueger:feat/tag-search-modes

Conversation

@aleksejkrueger
Copy link
Copy Markdown

@aleksejkrueger aleksejkrueger commented Mar 1, 2026

Add AND/OR and hash tag search modes #719

Motivation:

I wanted a better way to search for specific tags in my notes. The previous tag search was limited, so I built this to make it easier and more flexible to find exactly what I need. Now, searching by tags is much more powerful and enjoyable.

Features:

  • Added AND mode (+tag) to require all specified tags, and OR mode (default) to match any tag.
  • Added hash search (#tag) to find tags outside YAML frontmatter, with line and column info for each match.
  • Picker now shows matched tags, search mode (AND/OR), and only shows the file where the tags occur if multiple tags are passed.

Example usage:

  • :ObsidianTags #tag1 — finds all notes with the tag tag1 outside YAML frontmatter.
  • :ObsidianTags +tag1 tag2 — shows only files that have both tag1 and tag2 tags. 1
  • :ObsidianTags tag1 tag2 — finds notes with the tag1 or tag2 tags (OR mode by default).

This update makes organizing and finding notes by tags much smoother and more efficient.

Footnotes

  1. The first + before a tag is sufficient to activate AND mode for searching.

@aleksejkrueger aleksejkrueger changed the title add AND/OR and hash tag search modes (feat/#719): add AND/OR and hash tag search modes Mar 1, 2026
@aleksejkrueger aleksejkrueger changed the title (feat/#719): add AND/OR and hash tag search modes add AND/OR and hash tag search modes Mar 1, 2026
@neo451
Copy link
Copy Markdown
Member

neo451 commented Mar 1, 2026

decent proposal!

  1. need to properly document the DSL in docs/Tags.md and double check if this breaks current behavior
  2. to find inline tags, you can just look into how search.search_tags_async works, and identify which are inline and which are frontmatter, and differentiate with some boolean field in tag location type, like inline. of in_frontmatter. so that you can just filter them in the command implementation instead of read the files again.
  3. feat: obsidian search terms #542 is also on the roadmap, just for your reference, that one is AND mode by default, which makes sense for greping
  4. need some tests, can be tricky to write, I have not write any tests for the commands yet, just run the commands with the queries, and mock Obsidian.picker.pick, and verify the entries are correct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants