# List all highlights in document(s) — without community plugins

**URL:** <https://forum.obsidian.md/t/list-all-highlights-in-document-s-without-community-plugins/38984>\
**Category:** Plugins\
**Tags:** plugin-release\
**Created:** [June 15, 2022, 10:06am UTC](https://forum.obsidian.md/t/list-all-highlights-in-document-s-without-community-plugins/38984 "2022-06-15T10:06:55Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![CawlinTeffid](https://forum.obsidian.md/user_avatar/forum.obsidian.md/cawlinteffid/32/82899_2.png) [@CawlinTeffid](https://forum.obsidian.md/u/CawlinTeffid)\
**Post date:** [June 15, 2022, 10:06am UTC](https://forum.obsidian.md/t/list-all-highlights-in-document-s-without-community-plugins/38984/1 "2022-06-15T10:06:55Z")

</div>

I use highlights and comments to mark parts of draft documents that need attention, and I’ve been wanting a plugin to list them in a sidebar overview where I could click them to go to the text (similar to the highlight/comment functionality in word processors, but hopefully less clunky).

The closest community plugin I found was Extract Highlights, which copies a note’s highlights into the clipboard. I’d have to rerun it every time the highlights changed, and it doesn’t link to them, but I could get an overview when I wanted one. I discovered the plugin during a writing dry spell, so I haven’t used it much yet — and I’m not going to, because I can get what I want from an [embedded search](https://help.obsidian.md/Plugins/Search#Embed+search+results).

(EDIT: The Sidebar Highlights plugin appeared in 2025 and works with Obsidian’s comment and highlight syntaxes, which is great! It doesn’t support HTML conments yet, when last I looked.)

## An embedded search that lists highlights

This embedded search lists all of the highlights, and comments that immediately follow highlights, in a note named `Hyalite Manor`:

````
```query
/==[^(==)]*==( *(%%[^(%%)]+%%)|(<!--[^(\-\->)]+-->))?/ file:/^Hyalite Manor.md$/
```

````

I explain the regular expressions in the last section of this post.

As far as I know the results previews should always display the whole highlight (and comment, if any) because that’s what the pattern matches.

If 2 highlights are close together they’ll appear in the same preview. This can make the second one harder to notice, but I can live with it (the second one will become more obvious after I clear up the first one).

Clicking any result preview conveniently takes you to the highlight’s location in the document.

I’m so happy about this! 😃

## Variants

To avoid duplicate filenames, use `path:` instead of `file:` (for example, `path:Projects/Fiction/Hyalite Manor.md/`).

You could easily modify the search to collect highlights from multiple files.

If you put your comments [inside the highlights](https://forum.obsidian.md/t/extract-highlights-plugin/8763/101) instead of after them, you could remove more than half of the regular expression (this part: `( *(%%[^(%%)]+%%)|(<!--[^(\-\->)]+-->))?`).

If you only use 1 syntax for comments, you can remove the pattern that matches the other (see “Regular expression details”).

You could also collect comments that don’t immediately follow highlights. I didn’t because I use comments to summarize sections and I don’t want those summaries in my list of highlights. I’m planning to precede stand-alone comments with empty highlights (`====`), which is why the search matches those, but I could use some other convention instead. EDIT: Empty highlights are awkward; I’m using highlighted punctuation (`==+==`) instead to make it visible without affecting word count.

## Speed the process with a template

The fastest way to set this up for a file would probably be to make a template for QuickAdd and/or Templater, to do something like “create a new file using this one’s name with ‘.highlights’ appended, and put in it the embedded query for this file’s highlights”.

I don’t use either of those (yet?), so I’ll set up a template that either:

- makes the query with a placeholder for the filename (to be replaced manually), or
- uses the current file’s name to create the link and search together (after which I’d cut the search, follow the link, and paste it into the new file).

## Make it look more integrated

> [@Smoother looking embedded search (CSS snippet)](https://forum.obsidian.md/t/smoother-looking-embedded-search-css-snippet/107115):
>
> [Embedded searches](https://help.obsidian.md/embeds#Embed+search+results) are a handy way to gather or filter pieces of note content, but they look like the sidebar search widget plopped into a note. I prefer something that looks more integrated, so I use these CSS snippets to do that. Example (the colored text comes from an unrelated snippet): Embedded search body-style text.css /\* Style embedded search text like body text instead of small and faint. Courtesy of sailkite: https://discord.com/channels/686053708261228577/7026567346318…

## Regular expression details

Here is a breakdown of the regular expressions used, because regular expressions are hard to read. (This is the last section, so if you don’t care about this then you’re done. 😊)

The regular expression `/==[^(==)]*==( *(%%[^(%%)]+%%)|(<!--[^(\-\->)]+-->))?/`

matches a highlight `==[^(==)]*==`

optionally followed by a comment `( *(%%[^(%%)]+%%)|(<!--[^(\-\->)]+-->))?`.

The parentheses group things together so it works right. The question mark at the end makes the whole thing optional.

The comment can use Obsidian syntax `%%[^(%%)]+%%`

or `|`

HTML `<!--[^(\-\->)]+-->`

EDIT: The hyphens need to have backslashes in front of them to turn off the special meaning they have inside brackets.

The comment may be separated from the highlight by 0 or more spaces ` *` (that’s a space followed by an asterisk). I didn’t bother to make it handle tabs as well as spaces, but you could.

The expressions for each of the 3 syntaxes (highlight, Obsidian comment, HTML comment) follow the same pattern:

opening marker `==`

followed by 0 or more characters that don’t form the closing marker `[^(==)]*`.

The brackets there let me use the caret (`^`), which means “match anything except the following”. The parentheses make that apply to the pair of characters instead of just the first one — I think. I’m not sure they’re actually needed, but I don’t feel like looking it up yet. The asterisk at the end means to match the bracket expression 0 or more times.

I also use a regular expression to match the exact filename: `file:/^Hylit Manor.md$/`.

The caret means “beginning” and the dollar sign means “end”, so we only match the exact filename and not also, for example, `Sequel to Hylit Manor.md`.

## Changelog

2025-10-22:

- Added “Make it look more integrated” section linking to CSS snippets.
- Added mention of Sidebar Highlights plugin.

---

<div class="post-metadata">

**Author:** ![onkeltem](https://forum.obsidian.md/user_avatar/forum.obsidian.md/onkeltem/32/5540_2.png) [@onkeltem](https://forum.obsidian.md/u/onkeltem)\
**Post date:** [January 24, 2023, 10:09am UTC](https://forum.obsidian.md/t/list-all-highlights-in-document-s-without-community-plugins/38984/2 "2023-01-24T10:09:53Z")

</div>

Could you please show some screenshots? Or even better - a screencast. It’s really difficult to imagine what this is all about from the description.

---

<div class="post-metadata">

**Author:** ![CawlinTeffid](https://forum.obsidian.md/user_avatar/forum.obsidian.md/cawlinteffid/32/82899_2.png) [@CawlinTeffid](https://forum.obsidian.md/u/CawlinTeffid)\
**Post date:** [January 30, 2023, 2:44am UTC](https://forum.obsidian.md/t/list-all-highlights-in-document-s-without-community-plugins/38984/3 "2023-01-30T02:44:22Z")

</div>

Will do when I get a chance.

---

<div class="post-metadata">

**Author:** ![CawlinTeffid](https://forum.obsidian.md/user_avatar/forum.obsidian.md/cawlinteffid/32/82899_2.png) [@CawlinTeffid](https://forum.obsidian.md/u/CawlinTeffid)\
**Post date:** [January 30, 2023, 2:47am UTC](https://forum.obsidian.md/t/list-all-highlights-in-document-s-without-community-plugins/38984/4 "2023-01-30T02:47:21Z")

</div>

The community plugin [Comments](https://github.com/Darakah/obsidian-comments-plugin) adds a sidebar display of comments but uses its own HTML format instead of the existing syntaxes.

---

<div class="post-metadata">

**Author:** ![den](https://forum.obsidian.md/user_avatar/forum.obsidian.md/den/32/1932_2.png) [@den](https://forum.obsidian.md/u/den)\
**Post date:** [January 30, 2023, 12:28pm UTC](https://forum.obsidian.md/t/list-all-highlights-in-document-s-without-community-plugins/38984/5 "2023-01-30T12:28:40Z")

</div>

Can we exclude “==” from the results? There must be regex that is searching them, but exclude them from result string.

---

<div class="post-metadata">

**Author:** ![CawlinTeffid](https://forum.obsidian.md/user_avatar/forum.obsidian.md/cawlinteffid/32/82899_2.png) [@CawlinTeffid](https://forum.obsidian.md/u/CawlinTeffid)\
**Post date:** [January 30, 2023, 1:53pm UTC](https://forum.obsidian.md/t/list-all-highlights-in-document-s-without-community-plugins/38984/6 "2023-01-30T13:53:16Z")

</div>

You could probably do that with lookahead and/or lookbehind — see those terms at [Assertions - JavaScript | MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Assertions)

So you might be able to replace `==[^(==)]*==` with `(?<=(==))==[^(==)]*==(?=(==))` (if I haven’t made a mistake). This probably works best (or perhaps only) if you put the comments inside the highlights instead if after them.

---

<div class="post-metadata">

**Author:** ![den](https://forum.obsidian.md/user_avatar/forum.obsidian.md/den/32/1932_2.png) [@den](https://forum.obsidian.md/u/den)\
**Post date:** [January 30, 2023, 2:47pm UTC](https://forum.obsidian.md/t/list-all-highlights-in-document-s-without-community-plugins/38984/7 "2023-01-30T14:47:33Z")

</div>

There is some mistake it doesn’t work

---

<div class="post-metadata">

**Author:** ![CawlinTeffid](https://forum.obsidian.md/user_avatar/forum.obsidian.md/cawlinteffid/32/82899_2.png) [@CawlinTeffid](https://forum.obsidian.md/u/CawlinTeffid)\
**Post date:** [January 30, 2023, 7:16pm UTC](https://forum.obsidian.md/t/list-all-highlights-in-document-s-without-community-plugins/38984/8 "2023-01-30T19:16:32Z")

</div>

Sorry, try `(?<=(==))[^(==)]+(?=(==))`. I’ve also changed the `*` to `+` to guarantee at least 1 character between the highlight symbols.

---

<div class="post-metadata">

**Author:** ![Germanicus](https://forum.obsidian.md/user_avatar/forum.obsidian.md/germanicus/32/62721_2.png) [@Germanicus](https://forum.obsidian.md/u/Germanicus)\
**Post date:** [March 15, 2024, 12:31pm UTC](https://forum.obsidian.md/t/list-all-highlights-in-document-s-without-community-plugins/38984/9 "2024-03-15T12:31:01Z")

</div>

> [@CawlinTeffid](#):
>
> followed by 0 or more characters that don’t form the closing marker `[^(==)]*`.
> 
> The brackets there let me use the caret (`^`), which means “match anything except the following”. The parentheses make that apply to the pair of characters instead of just the first one — I think. I’m not sure they’re actually needed, but I don’t feel like looking it up yet. The asterisk at the end means to match the bracket expression 0 or more times.

I think you should get rid of the parentheses, otherwise your search will be broken if the highlighted text contains parentheses.

---

<div class="post-metadata">

**Author:** ![CawlinTeffid](https://forum.obsidian.md/user_avatar/forum.obsidian.md/cawlinteffid/32/82899_2.png) [@CawlinTeffid](https://forum.obsidian.md/u/CawlinTeffid)\
**Post date:** [March 15, 2024, 10:57pm UTC](https://forum.obsidian.md/t/list-all-highlights-in-document-s-without-community-plugins/38984/10 "2024-03-15T22:57:53Z")

</div>

They’re meant to group the paired equals signs. Does that not work inside brackets?
