A little more TextExpander

I don’t want to keep writing posts about switching from TextExpander to Keyboard Maestro, but if you’re interested in doing so, you should take a look at what Ryan M has done.

In my last post, I said

My first thought was that I could use Python’s plistlib module to turn an exported TextExpander library into a Keyboard Maestro library for importing. But while TextExpander’s plist format is very simple and easy to understand, Keyboard Maestro’s is distinctly more complex.

and so I punted on writing a Python script and built the klugey macro described in that post instead.

Ryan, though, is made of sterner stuff. He wrote the script I shied away from. It digs into your TextExpander settings file, extracts all the plain text, AppleScript, shell script, and JavaScript snippets, and builds Keyboard Maestro macros for each of them, saving them to your Desktop so they can be imported into Keyboard Maestro. It even preserves the snippet folder structure created in TextExpander.

I can’t say his script is bug free, but it successfully converted all the macros I’ve tested. And because it doesn’t mimic a person copying and pasting between programs (as my macro does), it’s very fast. Execute the command in the Terminal and boom—done before you know it.

I was amused by this passage from Ryan’s post:

I had been thinking this weekend whether it would be worth the time to try to migrate all my snippets to Keyboard Maestro. Browsing my Twitter feed, it looked as though Dr. Drang had beat me to it. Unfortunately he didn’t do the work I was hoping I wouldn’t have to do, and so I sat down to see how hard it would be to convert snippets to macros. Turns out...not that hard.

I’ll have to remember this the next time I want a well-written script. Post a half-assed one and wait a day or two until a real programmer comes along to do the job right.

There are a couple of things I’ll probably do before I use Ryan’s script for wholesale importing into my Keyboard Maestro library:

  1. As I mentioned in my post, in addition to moving the snippets from TextExpander to Keyboard Maestro, I want to change their prefix from “jj” back to a semicolon. I could do this by monkeying around with Ryan’s script, but I think it’ll be easier to use my reaffix script.
  2. Ryan’s script has the snippets inserted through pasting instead of typing.

    Keyboard Maestro insertion choice

    While pasting is distinctly faster than typing, sometimes pasting is forbidden, and the only way for a macro expansion to work is to mimic typing. Since my snippets aren’t especially long, I think I’d rather have them set to insert the resulting text by typing. That’ll mean tweaking his script a little to change how the action is carried out and eliminating the Delete Past Clipboard followup action. Shouldn’t be too hard.

Big thanks to Ryan for doing this the right way.