Advertisement

TextExpander Tip: Using the Clipboard in a Snippet



Along with Quicksilver, TextExpander is one of my must-have Mac utilities. TextExpander is a "snippet" utility that will automatically paste in content based on user defined abbreviations. For instance, I have "bc" set to expand to "because." However, the pasted text can be much longer (e.g. "sig" becomes a several line email signature). Today on the SmileOnMyMac Blog, I ran across a great tip I hadn't previously known about TextExpander (RTFM), viz. that you can use "%clipboard" as a variable in your snippets. When the snippet expands the clipboard content is automatically placed wherever "%clipboard" appears. The original tip involved using this to create Amazon.com links, but it quickly occurred to me that I could use this to easily create hyperlinks when for posting on blog comments (not TUAW) or on forums.

Oftentimes I want to paste a link into a forum post and I want to make it a hyperlink, not merely text. So all you need to do is add the following snippet to TextExpander, which I called "hlink":



In case you want to cut and paste, the Content is: <a href="%clipboard">%clipboard</a> Now when you want to paste in a link, just copy the URL to the clipboard (e.g. from your browser), and type "hlink" and you'll get the hyperlinked URL.

<a href="http://www.tuaw.com/">http://www.tuaw.com/</a>

Sometimes you don't want the text to be the link itself, so I created another snippet I called "htext":



The Content is: <a href="%clipboard">%|</a> When you copy a URL to the clipboard and then type "htext" it will paste in the URL with the cursor automatically placed before the </a> so you can immediately start typing your link text ("%|" will position the cursor at that point after expansion).


Of course this can be expanded to other uses too. I created a snippet called "hmd" that does the same thing for Markdown:



The Content is: [%|](%clipboard) Again, copy the URL to the clipboard, type "hmd" and the cursor is automatically at the right spot for putting in the link text.

Needless to say, this tip can be expanded in any number of ways. Be sure to check out the other options TextExpander allows, including date and time variables, cursor placement, and delimiter abandonment (convenient for addresses and telephone numbers, etc. in forms).