Search in a page and all its linked notes?

What I’m trying to do

Is it possible to limit a text search to a page as well as all of the pages that it links to or that link to it? This would be a gamechanging feature for me, but I haven’t figured it out yet.

1 Like

I don’t know if there’s a better way to do this, but it’s easy to do with Dataview:

const searchString = 'asdf'

const me = dv.current().file
const matches = [,]
  .filter(async (page) => {
    const file = app.vault.getAbstractFileByPath(page.path)
    return (await RegExp(searchString))
  .map(x =>


Paste this into any page, and it will search the inlinks and outlinks for that page for the string asdf (or whatever you specify for the searchString variable).


Using the sidebar search, where “term” is your search term and “note” is your note name: term (file:/^note$/ OR /\[\[(.+/)?note(\||\[)/)

(This assumes no duplicate note names.)

Not something you want to type every time, but you can save it (using the core Starred plugin or as an embedded search) and replace the term and note when you use it.


file:/^note$/ uses a regular expression to match the note name exactly (^ means the start of the string and $ the end).

The regular expression /\[\[(.+/)?note(\||\[)/ matches

  • 2 left square brackets,
  • optionally followed by any number of characters ending with a slash (in case the link includes a folder),
  • followed by the note name,
  • follows by either a pipe or a right square bracket.

Square brackets and pipes both mean things in regular expressions, so most of them are preceded by backslashes to mark them as just plain text, making the whole thing harder to read.

1 Like

It was hard to pick just one solution. Thank you both!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.