Search headings when referencing notes

It would be useful if the headings are included into autosuggested values in [[...]]].

For example, I am trying to refer to a particular idea summarized by a heading within the same note, currently the autocomplete suggestions do not include the desired headings:

This, combined with the ability to update references to a note’s heading, would be powerful, enough so that I can adjust my habit to avoid needing Block References.

Clarification

I mean when I type something in [[...]] , I want headings matching that are also included in autosuggested values. Currently, only the titles of the notes are included.
I can reference a heading given the title, but I am asking for relevant headings without knowing a note’s title, since the title may summarize a broader context than a specific heading that I want to refer to.

5 Likes

That feature already exists. When you start the link to a note with [[ Obs will present a list of notes, incl. the one you’re after. Rather than clicking on the relevant note, hover over it, then click #, which will present you with a list of hash headers in the note. Click on the relevant header. Done. Your link will be [[note name|#header name]].

I think I haven’t made my request clear.

I mean when I type something in [[...]], I want headings matching that are also included in autosuggested values. Currently, only the titles of the notes are included.
I can reference a heading given the title, but I am asking for relevant headings without knowing a note’s title, since the title may summarize a broader context than a specific heading that I want to refer to.

Well, if your request was clear I would not have replied the way I did. Nevertheles, I apologise for wasting your time, it won’t happen again, I hope.

1 Like

Thank you. I have updated the request with a clarification.

1 Like

Second that request. It would be good if there was a setting to also index headings into the [[ menu (similar to the [[## menu).
If there is an API to do this, I’d look into building a little plugin for it (need pointers)

1 Like

The Another Quick Switcher plugin already does (some of) this, but not in the editor alas (as far as I know).

I recently learned of this through @CawlinTeffid; it is really valuable and it is a very little known feature. Quickly made a Typing Transformer shortcut for it.

I tinkered with plugins for the first time and got what I wanted to work.

But it relies on patching obsidian functions which doesn’t seem very safe.
Wouldn’t mind some input on better ways to do this.

Or better yet, one can use this Templater snippet:

<%*
const editor = app.workspace.activeLeaf.view.editor

// The text selected before running the template
const selection = editor.getSelection() || ''

// Preface the selected text with [[##
const link = `[[##${selection}`

// Replace the selection with the generated link
editor.replaceSelection(link)
_%>
  • Select text in editor, run the snippet.


I tried compiling a main.js from .ts, but ran into errors (my first time doing this).