Live Preview Inhibit / disable automatic link address expansion

I navigate and edit as much as possible by keyboard, but in Obsidian, this is unusually messy, as Obsidian expands a link any time you put a cursor on it. When the suddenly-displayed link address is long, this can displace the cursor by several lines and many columns, which disrupts keyboard operation. I only want to see this address when I want to edit it, which is rarely.

This feature request would be to only expand links when asked to, and when asked, to make a popup or something like that. I’ve showed examples of how this is done by other popular programs in this help request: How to inhibit automatic link address expansion?

3 Likes

Use case or problem

I’m editing a note, moving the caret around willy-nilly. As soon as the caret dares to touch a hyperlink, it expands in size, moving all the text around, triggering a cascade of line breaking that affects the flow of text all the way to the bottom of the document. Some URLs can be really long, like 4 lines long, so I always dread putting my caret on them, for when they expand, they shake and move the heaven and the earth. I’m often wary of even adding links to my notes, because I know that whenever I’ll edit the document it’ll be shaking and quaking the entire time.

Proposed solution

A simple setting to turn off link expansion. Then when I’ll want to edit a link, I’ll just press Ctrl-Shift-P to go to source mode. Then I will finally be free to edit my notes without the links expanding and contracting like a firefly’s abdomen during the mating season.

I used the following ai-generated snippet to prevent link expansion. It works, but now I don’t know how to edit the links anymore :woman_shrugging:

  1. Settings > Editor > Auto-pair brackets must be disabled. Otherwise, the snippet does not allow you type left brackets.
  2. Settings > Appearance > CSS snippets add the following:
/* Hide URL only in complete links (has cm-string but NOT cm-hmd-barelink) */
.cm-url.cm-string:not(.cm-hmd-barelink) {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
}

/* Also hide the parentheses around complete URLs */
.cm-formatting-link-string {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
}

Once you put the final paranthesis in [xxx](www.xxx.com), the url becomes invisible.