Creating Markdown Links with Keyboard Maestro

In a past episode of The B&B Podcast my co-host Shawn Blanc was giving me some grief over the fact that I didn’t have a keyboard shortcut setup for Markdown links in TextMate. Being a TextMate fanboy I knew that I could create a solution using bundles, but honestly I have never done that before and that thought of spending that much time concerned me. Instead I knew that I could create a solution using the best weapon I have at my disposal: Keyboard Maestro.

In MarsEdit you can select text and hit the shortcut: Shift+CMD+A to paste the current url on your clipboard and set the selected text as a link to that url. It is all pretty damned easy and I really like the way the system works in MarsEdit and I really like the shortcut key. So the question became: how do I make that a universal shortcut on my Mac that does the same thing for any text anywhere.

It was actually pretty easy. Here’s how I did it with Keyboard Maestro:

  1. Create a new Macro and set the ‘Hot Key’ trigger to: Shift+CMD+A.
  2. Tell Keyboard Maestro to execute the CMD+C or ‘Copy’ action.
  3. Add the ‘Insert Text’ action and tell it to paste the following: [%CurrentClipboard%](%PastClipboard%1%)

You are now down. Any text you select anywhere on your Mac will now be converted to a Markdown link, which is great for people like me who go back through blog posts in TextMate, entering in new links. But wait, there is one obvious problem here — this macro will have a conflict in MarsEdit, especially if you use MarsEdit in HTML mode and not in Markdown.

Keyboard Maestro provides an easy work around for this. Create a new macro Group and label it something like ‘Not in MarsEdit’. In the editor for that group (just select the group folder) change it so that the macros in that group are ‘Available except in the following applications:’ and then just add MarsEdit. Now you have made it so that any macros housed in this group are disabled when you are working in MarsEdit. Last step then would be to move the Macro you just made into this group (by dragging it).

Done.

[Updated: 3.23.11 at 3:23 PM]

Reader Drew Franklin tweeted to me that TextMate already does this using the Hyperlink Helper bundle and the shortcut: Control + Shift + L. Though I still prefer my universal solution it is nice to know that you can do this with no work.

Originally posted for members on: March 23, 2011
Follow along on RSS, App.net, or Twitter.
~I would appreciate it if you considered becoming a member.~