Linking from display text to link

Hello, I’m new having trouble with the linking feature.

I understand that in order to make a internal link from text, you just select the words you wanna make a link with, then just press ‘[[’ or ‘]]’ and it will automatically make a link for it, after that you can just press → then use pipe to display text from.

My problem is that I tend to write the paragraph first, but sometimes I want to make a link on the go from the previous sentence, example:

Suppose I have a paper names “This is a paper”, and I want to link this note from a text where I selected the previous word and make a internal link, but the words I selected should be the display text then after that I specify the note/header I’m linking which is “This is a paper”, It’s seems possible at first but when I try to do it backwards then pipe, its inconsistent.
Also I’m searching a quicker way to do it, bassically what I close in brackets first should be the display text, then it should give me the option to link a note after without pressing arrow keys every time. Also the pipe symbol is really weird in my keyboard, I have to press like “Alt Gr” and ESC for it to work, it’s like 4 keys for a simple task.

In this gif I show what I’m trying to do.

0b2cbd4284fe0cb7b93cd0e333914fbf

If you know you’re going to make that link, why not just type the double brackets, start typing the link, select it and type the pipe symbol and add the alias?

To me that is a lot faster than selecting the text, and do various stuff to get it to be an internal link. In fact, even when I go back to add a link I often just erase the text and do as described above.

1 Like

Hello!

If i understood your case correctly, usually I do it on of those 3 ways:

  1. just open bracket [[ and start writing ‘paper’ (like @holroy mentioned in prev comment)
  2. selecting word like you and than backspacing list letter inside, it will make it ‘pape’ and start searching. works instead of that pipe trick you trying to do
  3. pressing cmd+shift+f to call global search and typing ‘paper’ there, it will search paper everywhere and then you could drag’n’drop exact note you need into text

Suppose I don’t know that I’m planning on making that link at first, I’m just typing a concept, then in the middle of the paragraph, I remember I have a note for that. I understand this is a really simple task you can do at the moment, but I wanna work with that flow as seems really natural for me.
Or in fact I’m just reading it again, doing a review, then I just select text and use that as display text for linking, not even modifying anything.

To each their own, and that is as it should be. Would the following be a little easier for you to do:

  • Write some text like you’ve always done, and select the word(s) you want as display text, and type the [[
  • Hit left arrow, , and type the pipe character, |
  • Hit the left arrow again, , and then start typing to get auto completion on the note you want to link to
  • When found hit enter, and continue typing more text

Another option without as many arrow keys:

  • Write some text, select the words to use as display text, and hit Cmd-X (or Ctrl-X) to cut out the text
  • Start doing the [[ , and auto complete the note you want to link to
  • When found, hit Tab, the pipe character, |, and then Cmd-V, and enter

The problem with cmd+shift+f is that it still search the keywords I’m selecting, just asumme the selected text doesn’t have any keyword in common, and it’s just a display text doesn’t matter what, the workflow and steps are these:

  1. I just select a random sentence typing/reviewing my text.
  2. I press a shortcut then the sentence becomes the display text.
  3. The file I’m trying to embed may or may not have anything related to the text I selected.

Example:
I have the note named:

ABOUT NOTE

I have the next text:

Hello this is a random sentence.

Then I proceed to select “random sentence”.

Hello this is a random sentence.

Then somehow random sentences becomes the display text, and I have the simple task to search for that note just like you would search any other note, then it links and becomes:
[[ABOUT NOTE|random sentence.]]

Yeah that is what I’m doing so far, but maybe this could become a script somehow, or there is an actual keyboard shortcut/addon where this is suported just as a keyboard combination, in my keyboard is really hard to do that sequence naturally, and those are like 8 combinations with my keyboard lang.

I added another option to my previous post, without the arrow keys, which might be better?

1 Like

Adding to this: The second options seems more reasonable, still would be amazing to have a shortcut for that in my case, that could happend just like “CTRL + Q” or anything I can bind it for.

OK, now I might be on to something useful.

One time setup

If not done already install the Templater plugin, and create a template like the following:

[[<% tp.file.cursor() %>|<% tp.system.clipboard() %>]] 

Goto Settings > (Community plugins) Templater > Automatic jump to cursor, and enable it, if not done already. Continue down to the Template Hotkeys settings, and hit the Add new hotkey for template.

Locate your template, and hit the plus icon, and assign a hotkey to your newly create template command, i.e. cmd+opt+Z.

Now return to typing your documents…

How to use

  • Write your wonderful paragraph, and decide you want to link something. Select it, and hit Cmd+C to copy it to the clipboard
  • Hit your hotkey sequence, cmd+opt+Z
  • Autocomplete the link to the note, and hit enter, and continue typing

No pesky pipe character or arrow keys to type anymore. They’re automagically inserted!

2 Likes

This was a actually a great idea, @holroy, why don’t you do that in your own vault? I think I’ll do just that:

  • Add the template, PresetDisplaytext:
[[<% tp.file.cursor() %>|<% tp.system.clipboard() %>]] 
  • Add hotkey, Cmd+Opt+C to this template (and be sure to enable the automatic jump to cursor)

And then when you want to use it you do:

  • Select display text
  • Cmd+C followed by Cmd+Opt+C
  • Autocomplete the note you want to link to

Nice solution, @holroy. :smiley:

2 Likes

Well this is an advance, just in case, if you could fix the next 2 things it would be amazing:

  1. Is there a possibility that you dont need to copy it? like some sort of selected() method or something like that?.
  2. When I do the bind, it actually works, but the cursor ends before the “[[” brackets, so I still have to do 2 right arrows, is there a chance for it to move exactly between “[” and “|”?

Thanks you’re really helpful!

Okay I’m looking at templater documentation, I don’t think there is a possibility of doing that, or atleast I don’t understand how, for some reason obsidian decides to place the cursor before the “[[”, I made it a little bit better using a tp.file method which is selected, I don’t even need to copy it.

[[<% tp.file.cursor() %>|<% tp.file.selection() %>]] 

Still it doesn’t seem to work with “[[ ]]” because it automatically places the cursor before the link, it looks like a obsidian function, maybe it’s possible to work around it.

It did work for me, and it do place the cursor within the link for me. Not sure what’s happening at your end if it continues to do that.

I don’t know/think it’s able to do the copy, but if you do the combination with the b similar hotkeys it’s very fast to do it.

I already fixed it, the template is:

[[<% tp.file.cursor() %>|<% tp.file.selection() %>]] 

It uses the selected input I don’t even need to copy it. Also the problem with the two brackets fixed by itself don’t know why, maybe some internal spaghetti.

4 Likes

Oh, as I said “I don’t know…”. I’m glad you proved me wrong. That’s a neat little function, and as you might understand I’m still learning about what’s available in the various plugins and code library.

1 Like

Your solution was really helpful and I appreciate it, didn’t know the existence of this cool addon, I found about obsidian not that long ago because I needed a lightweight text editor, but .md files are enough for my understanding.
Thanks you, I don’t know how to close this thread but I expect more people to find the same answer if they step on the same problem as me, or maybe I’m just weird for using a bind like that :sweat_smile:.

tyvm.

Under the various replies, you’ve got a button for choosing to mark that reply as the solution, and then the thread is considered closed.

It’s still available for reading and comments for a while.

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