Jump to content

How to set up a keyboard shortcut for turning selected text into a Markdown link?


Recommended Posts

Hi. I frequently find myself turning text in a Markdown document into a hyperlink of the form `[link text](url)`. Usually, the link text already exists, and I've got the URL in my clipboard from having just visited it in a web browser and grabbed the address.


What I currently do is: Place my cursor at the start of the text to link; type a `[`; move the cursor to the end of the link text, usually with option-right arrow one or more times; type `](`; paste in the URL; and type `)`.

 

What I would **like** to do is: Select the text to link; type a keystroke that acts as an Alfred trigger; and have Alfred automatically replace the selected text with `[selected text](clipboard contents)` including all the brackets and parentheses exactly as shown.

 

Is this possible? How?

 

Thanks…

Link to comment

Welcome @IDB,

 

2 hours ago, IDB said:

Is this possible?

 

Very much so. Here’s a Workflow with a version of how I do it.


You select the text, press the shortcut, and it converts it to [selected text](url). You don’t need to have the URL as your most recent copy—which I found sometimes doesn’t happen and can be annoying—as the Workflow will search your clipboard history for the past thirty entries and use the most recent one which starts with http.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...