Simple plugin to link selected text to a note while maintaining that text as display text

Here is the use case:

  • I’m in a note with text that includes the word “Impressionists”
  • I want to link that word to a note titled “Impressionism”, but I want to maintain the original display text.
  • So I select the word “Impressionists”, trigger the plugin (preferrably with a hotkey)
  • A note selector opens up (i.e. the Quick Switcher), I find the “Impressionism” note and select that.
  • The originally selected text should now be replaced with [[Impressionism|Impressionists]], so that the diplayed word “Impressionists” is now linked to the note on “Impressionism”.
  • Success!

Does this already exist? If not, I would love to create it but have no plugin dev chops.

I select a word …

image

… then via hotkey I trigger …

image

… only problem that I have is that the cursor is at the end, but it would be nice if it’s at the beginning* …

… so after moving the cursor to the beginning and adding a vertical bar (|) I got dropdown where I choose linked file.

More about changing link display text: Internal links - Obsidian Help

Oh, and I believe it can be simplified with some Templater or code snippet, but I’m not using it very often.

Cheers, Marko :nerd_face:

2 Likes

Thank you! This does work for me. So there is a very specific set of steps.

  • Highlight my text “Impressionists”
  • Pres [[ to trigger creation of a link
  • Jump to the beginning of the word and add the vertical bar/pipe
  • Start typing the note I want (“Impressionism”) and hit Enter to select.
  • Et voilà! It works, thanks!

I guess I will learn plugin development another day. :grin:

1 Like

If you start selecting from back to the front of the word, after adding [[, the cursor is already at the beginning of the word :slight_smile: … or, on Windows, you can use Ctrl + left to jump the entire word, not just one letter.

I hope that this “temporary shortcut” doesn’t distract you from your desire to learn plugin development. So I’ll hold you for the word “another day”! :smile:

Due to the rules, plugins can be complex, but there’s nothing to be afraid of. So, maybe you start with simple code snippets, which I’m sure you can achieve in your workflow with it.

This is my post on how I started with code snippets: [Hotkeys] Assigning "longer sequence of the key combinations". It’s a good example of how the community is open to newbies and helps them out. And some basic steps, very well described.

Keep coding! Cheers, Marko :nerd_face:

1 Like