Command Palette / Right click menu item to generate block and header reference

There should be a fast way to generate a block id related to the current line or the current header and copy it to clipboard.

11 Likes

Use case or problem

It would be cool if there is an option to copy, possibly the markdown link to any block or heading by right-clicking and choosing copy on

  1. The Outline
  2. The Paragraph/Heading in edit/Preview modes

Proposed solution

Current workaround (optional)

Right now block links and heading links have to be created via the popup search which is available by pressing [[.

4 Likes

Agreed! This missing threw me for a loop when I switched from Roam :blush:

3 Likes

Use case or problem

Regularly, I want to link to a section in some file, while this section is easily accessible (typically, I am switching between two files and one of them has the section I want to link to). Do we have a general and fast method for linking to this section from another file? As far as I know, we don’t (see the workaround section below).

Proposed solution

When right-clicking on a section header, we would get a “Copy header link”. The link would be useable in any [[…]] link (so would contain the file name).

Of course, “Copy header link” would also be available as a command (for use on a phone, for fast keyboard access, etc.).

Current workaround

Currently, I see two ways of inserting a link to a (deep) section in another Obsidian file, after opening a link with [[ and starting to type a file name, but the first one is slow and painful, and the second one doesn’t always work:

  1. Type # and then browse section names one by one. This is slow, when sections are deep, especially since we need to remember the names of all the intervening sections (before the one we’re targeting).

  2. Type ## and then some words of the section header you’re linking to. The big problem is that you can really have a file where many sections have the same name (let’s say “Ingredients”, in a list of recipes from a book), so it can be essentially impossible to select the right one.

Simply right-clicking on a section header and copying its link (or running a “Copy header link” command) would solve all of this neatly!

Thanks!

3 Likes

I concur this would be most useful

1 Like

You can type here to narrow the list, same as with ##.

This is only needed if you don’t remember which file the heading is (or if you just like to type the same thing each time instead of remembering 2 ways).

I personally avoid having many duplicate headings in a file and would recommend the same (but of course it’s not wrong to have them).

All that said, I support the request.

It’s indeed not wrong to have the same heading multiple times in a single note: I was citing the example of a notes with (say favorite) recipes, but this could be book reviews:

# Book title 1

## Positive points

## Negative points

# Book title 2

## Positive points

…

Selecting the right sub-section (or sub-sub-sub-section…) can be quite painful.

Huh… how will obsidian differentiate between the links to headings with the same text? Does it insert block links?

Use case or problem

I am trying to very quickly copy a link to a visible heading and paste it into another note that is also visible.

Proposed solution

Sorry that this is kind of a double feature, but the idea is that the little anchor, perhaps visible only during hover, would allow us to either single click it, to copy heading link to clipboard, or drag and drop it, to copy and paste heading link to the release point. I would be happy to split these into to separate requests, but kind of like them together.

Current workaround (optional)

I can type [[ then type ## and begin typing the heading name and quickly get a link to it from anywhere in vault. I actually have a macro set up to type [[## and another for - [[## because I find myself doing these so often.

Thanks so much!

Some other workarounds:

  1. You could right click a header and select “copy heading link”
  2. You can use the Drag and Drop Block plugin where you can use alt+drag and it will paste the heading link to the release point
1 Like

Thanks @DEV_Scribbles ! That would be great! Unfortunately, for me, the right click “Copy Heading Link” does not show. That seemed like it was the most likely and might have been the first thing I looked for once I decided I needed something more efficient. I am not seeing that as an option. I only see options for extracting and renaming. Maybe I am missing something.

Regardless, I really appreciate your reply, and the heads up on that plugin!

OMG I just checked and it turns out the Copy Heading Link was from the Copy Block Link plugin :see_no_evil:

3 Likes

I didn’t even think about that when I answered. :woman_facepalming: I would expect Obsidian to go to the first one on the page, which I think is what web browsers do.

Yeah, I wouldn’t do that — I give recipes and books their own notes. (But do whatever works for you.)

Also, as holroy points out, a heading link to a note that contains multiple copies of the heading may not link to the heading you want (I think it’ll link to the first on the page but I haven’t tested). In that case you’ll need to use a block link.

Also, a post in the thread this has been merged with points out a plugin that adds the feature you want. Command Palette / Right click menu item to generate block and header reference - #12 by DEV_Scribbles

1 Like

Desperately need this.

Now that we have “Bookmark this block”, could we get a “Copy link to block” option pleeeassseee. It’s timeconsuming doing it manually via [[]] and then ^ at the moment. Thanks! :pray:t3:

CleanShot 2023-05-29 at 23.01.50

3 Likes