Skip to content

[Feature Request] Keyboard shortcut for "reference-style" links #982

Closed

Description

@willhbr

I would really like it if the cmd-k shortcut for inserting a link could insert reference-style links instead of (or as well as) inline links. By reference style I mean where the link is on a separate line and a unique identifier associates the URL with the linked text:

This is [an example][id] reference-style link.

[id]: http://example.com/

Usually if a link is particularly long I will use the reference-style to avoid adding too much noise to a particular paragraph.

How I imagine the interface could work would be for me to select some text, press cmd-k, have the selected text be wrapped in a square brackets, the link added from the clipboard on the next line, and then keyboard focus be in (both?) the places where the reference needs to be inserted.

You could have a simple heuristic to guess an ID based on the domain name (like example for example.com/whatever).

Thanks!

Activity

  1. cyanzhong commented on Aug 3, 2025

    @cyanzhong
    Contributor

    Thank you for the suggestion. I think what kind of link should be inserted with Cmd-K is largely a matter of personal preference. Personally, I rarely use reference-style links, but I also don't want to turn this into a configurable setting.

    That said, I believe this need can be addressed well via an extension — please check MarkEdit-reference-style-links out.

    Image

    As for the selection part, I may not have fully understood what you meant — please feel free to clarify your thoughts.

  2. willhbr commented on Aug 3, 2025

    @willhbr
    Author

    omg that's amazing! I agree this is pretty fiddly to add to the main app. The behaviour you've implemented with selection is what I was imagining.

    I've tinkered on it a bit further to look for existing references with the same URL, and a very personal taste feature of inlining URLs that are <20 characters long. I've put that repo on Codeberg.

  3. cyanzhong commented on Aug 3, 2025

    @cyanzhong
    Contributor

    Cool. Feel free to use my approach as an example to do what you want.

    By the way, I have updated my repo to make the keyboard shortcut configurable (without rebuilding).

    Closing this now, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions