Automate Text Expansion

Even if you’re a great typist, you can save time and increase your accuracy with software that watches what you type and dynamically replaces abbreviations you’ve previously specified with longer chunks of text. (And if you’re not a great typist, such software can increase your effective typing speed!)

I mentioned earlier that whenever I type dtpo, my Mac automatically expands that into DEVONthink Pro Office. That’s just one of dozens of abbreviations I use in my own work. I also use TCo to produce Take Control of, syp to produce System Preferences, and so on. The longer and more complex the text in question, the more useful automatic text expansion becomes.

Text expansion isn’t just for names and short phrases. You can use it for addresses, phone numbers, URLs, boilerplate text for common email replies, HTML code snippets, and so on. Depending on which software you use for text expansion, your snippets might also include styles (such as bold and italic), graphics, the current date or time, variables, AppleScripts or shell scripts, the contents of the clipboard, and more.

The great thing about text expansion is that you don’t have to do anything special to use it—you simply type. You don’t need modifier keys like Command or Control, and you don’t need to hunt for menu commands. And it can be used nearly anywhere.

One catch, however, is that you must be careful when choosing abbreviations—since text expands as you type, you might end up making a lame mistake if you’re not paying attention. For example, I thought I’d use km as an abbreviation for Keyboard Maestro, but then I tried typing a distance in kilometers and got a surprising result! So be sure to use abbreviations that will never occur on their own, or even as part of another word. One technique many people use to solve this problem is to double the first or last letter, as in kmm for Keyboard Maestro.

Note: Although I say “text expansion,” the very same feature can be used for simple replacements, even if the replacement isn’t longer. For example, if you frequently mistype “the” as “teh,” you could use text expansion to replace the latter with the former—or you can correct “MacWorld” to “Macworld” and “PhotoShop” to “Photoshop.”

Use OS X’s Text Replacement

OS X includes its own rather rudimentary text-expansion capability, known as text replacement.

To configure text replacement:

  1. Go to System Preferences > Keyboard > Text (Figure 13).
    **Figure 13:** Set up OS X text replacements here.

    Figure 13: Set up OS X text replacements here.

  2. Click the plus button.
  3. Type the text you want to type in the left-hand (Replace) field, and then type the text you want to end up with in the right-hand (With) field.

    Tip: Although replacement text can’t include a Return character, you can type Option-Return to include a line break.

  4. Press Return.

Repeat these steps as many times as you like to add further abbreviations.

Once configured, text replacement is seamless: you type one of your abbreviations, and as soon as you press a trigger key—Space, Tab, or Return, or a punctuation character—the abbreviation is replaced with the text you’ve specified. Abbreviations are not case-sensitive, so if you set up myurl to expand into http://www.myurl.com/, then that will happen even if you type MyURL.

And, your abbreviations even sync across your Macs and iOS devices if they’re all signed in to the same iCloud account and Documents & Data is selected in the iCloud pane of System Preferences.

Although text replacement works well enough for what it is, this feature has numerous limitations:

So, if you like the idea of text expansion but find OS X’s built-in feature too limited, it’s time for a more powerful, third-party tool.

Use a Third-party Text Expansion Utility

For vastly more power and flexibility when it comes to text expansion, turn to a third-party utility. At the moment, I’m aware of four main contenders for OS X that are under active development: aText, TextExpander, Typinator, and TypeIt4Me.

These four tools share many features in common beyond mere text replacement—for example, all of them can:

These four utilities are much more alike than different, and most users should be equally content with any of them. I will, however, point out a few distinguishing characteristics:

What I use: I was a TypeIt4Me user for a long time, but while I still like it, I now prefer TextExpander. It receives more frequent updates and I find its user interface more appealing. aText looks great too, but not great enough for me to switch from TextExpander.

The more time you spend working with a text-expansion tool, the more ideas you’ll come up with for putting it to good use. Here are a few I haven’t mentioned already:

Just to show you how this works, let me walk you through the steps of creating and using an abbreviation in TextExpander:

  1. Open the TextExpander app.
  2. Click the New Snippet button.
  3. In the Content area, type the text you want to end up with, such as supercalifragilisticexpialidocious.
  4. In the abbreviation field, type the abbreviation you want to use, such as scfl. (Be sure not to reuse an abbreviation you used in System Preferences > Keyboard > Text.)
  5. Close the TextExpander window.
  6. Now open an app where you can type text—for instance, TextEdit or Mail.
  7. Type your abbreviation scfl and then a space or other punctuation. With a “pop” sound, your abbreviation disappears and is replaced with “supercalifragilisticexpialidocious.”

Clean Up Your Text with TextSoap

Text expansion is handy, no doubt about it, but sometimes your text needs help of another kind. For example, do you often find extra spaces or return characters, duplicate lines, or text in the wrong case? Do you find URLs or dates in the wrong format, styled text that should be in HTML or Markdown instead, or other annoying errors? An app called TextSoap can solve these and thousands of other problems, often with one click. (We’ve even included a coupon at the end of the book so you can buy it at a 20-percent discount.)

Where a built-in solution isn’t quite what you need, you can make your own with a combination of regular expressions (a powerful pattern-matching system) and styles, and you can even build elaborate multi-step macros to manipulate text any which way. In that sense, it’s somewhat like a subset of Nisus Writer Pro (see Automate Nisus Writer Pro)—the Find/Replace capability and a portion of the macro language, but without all the other word-processing features. Anyone who works extensively with text is bound to find many uses for such a tool.