Textexpander snippet for Searchlink

If you’re writing anything that refers to internet sites, Brett Terpstra has a useful service that will allow you to return a markdown-formatted URL for a search term without ever opening a browser. It’s called Searchlink and I use it multiple times a day.

Searchlink has extremely simple syntax, it looks like this:

[text to link](!arg "optional search text")

Way faster than popping open your browser and searching, then copying a URL. But I kept mistyping arguments, and typing the syntax sometimes slowed me down, so I created a TextExpander snippet that makes putting in a link almost seamless:

[%filltext:name=Link text%](!%fillpopup:name=Search in:default=g:wiki:a:crateofpenguins.com:def:mas:itu:s% "%filltext:name=Link text% %filltext:name=Optional search text%")

Put this into a new plain-text snippet, give it an abbreviation, and you’ll be good to go.

As you can see one of the arguments allows me to search my own site, in case I want to quickly pop in a reference to a previous article. You’ll also notice that the optional search text is by default the same as whatever you typed as the text to link: this stops it breaking if you don’t enter any additional text to search on. Once I’m done writing, I have a system-wide keyboard shortcut set up which runs Searchlink on any selected text.