Mac OS X 10.6 Snow Leopard includes a number of new text-related features, including automatic spelling correction and text substitution. These features are supported in Apple-supplied applications like Apple Mail, Safari (in text areas), TextEdit, and AppleScript Editor, along with independent applications that use the appropriate Apple technology - relatively few at the moment, but more are undoubtedly on the way.
(One tip: The automatic spelling correction is seldom enabled by default. To turn it on, make sure the insertion point is somewhere where text can be entered, and either choose Edit > Spelling and Grammar > Correct Spelling Automatically or, if the Edit menu's submenu doesn't have what you need, Control-click where you're typing and choose Spelling and Grammar > Correct Spelling Automatically from the contextual menu that appears. The latter approach is particularly likely to be necessary in Safari and other WebKit-based applications, like Mailplane. Text substitution doesn't need to be turned on.)
The automatic spelling correction compares what you type with words in Mac OS X's internal dictionary, automatically replacing mistakes with what it believes you meant to type. The text substitution feature relies instead on replacement pairs - a specific mistake coupled with a specific replacement.
As a result, although the automatic spelling correction can fix mistakes that no one would have anticipated, it can also guess incorrectly. In contrast, the text substitution feature knows only about the mistakes you've taught it, but it will always do the right thing when you make a known mistake.
So here's the problem. Let's say you type the text "wth" because you want to enter the word "with". Snow Leopard's automatic spelling correction replaces "wth" with "wt." for some reason, causing you more work than if it had done nothing at all.
Luckily, Snow Leopard's text substitution feature overrides the automatic spelling correction, so if you create a replacement (in the Text view of the Language & Text pane of System Preferences) that replaces "wth" with "with", that mistake will be corrected properly in the future.
Unfortunately, Apple's replacement dictionary has very few entries and adding them is tedious, so I set out to find where and how they are stored, enabling me to bolster them with the public domain TidBITS AutoCorrect Dictionary initially created for use with Eudora (see "An ATypoKill Eudora Hack," 2000-09-04). (Subsequently, the TidBITS AutoCorrect Dictionary has been made available for Typinator, TextExpander, and TypeIt4Me, which also offer many other capabilities beyond Snow Leopard's.)
[Editor's Note: Testing the automatic spelling correction feature in Snow Leopard has been extremely frustrating. It doesn't seem to work all the time when you intentionally type misspelled words, and it doesn't always kick in instantaneously. The feature is certainly a help in general, but right now, the connections feel a little loose. -Adam]
The Basics -- After a little digging, I found that Apple stores the replacement pairs in an invisible file at ~/Library/Preferences/.GlobalPreferences.plist, and the pairs have a data structure that looks like this:
Next, I took the TidBITS AutoCorrect Dictionary, reformatted it to the appropriate structure, and pasted it into the .GlobalPreferences.plist file. To test it, I typed a few of the typos in the file into TextEdit, and watched them be replaced.
The only question is if putting over 2,700 replacement pairs into the .GlobalPreferences.plist file will impact performance, particularly on slower Macs. In initial usage on several machines, including a Mac Pro (Early 2008) and a 2009 MacBook Pro, it has seemed fine, though there was a bit of a slowdown on a Mac Pro (Early 2006). Leave a comment if you see any performance problems after adding all these entries to your .GlobalPreferences.plist.
Do It Yourself -- If you would like to try this out yourself, TidBITS has made my reformatted TidBITS AutoCorrect Dictionary available for download.
Once you've downloaded and expanded the file, follow these step-by-step instructions using either BBEdit or the free TextWrangler, also from Bare Bones Software. (The .GlobalPreferences.plist file is saved as a compressed plist, so a program like TextEdit or vim/nano won't be able to read it properly without additional steps.)
- Open the Language & Text preference pane.
- Click the Text button to switch to the Text view.
- Click the + button and add a new replacement. I suggest "teh" and "the".
- Open the reformatted TidBITS AutoCorrect Dictionary in BBEdit or TextWrangler, select all (Command-A), and copy the text to the clipboard.
- In BBEdit, choose File > Open Hidden.
- Navigate to your home folder, then Library, then Preferences and select the .GlobalPreferences.plist file.
- In that file, find the replacement pair you added (search for "teh").
- Select the entire dictionary entry (from dict to /dict).
- Paste the contents of the linked file from before over the "teh" dictionary entry.
- Save the .GlobalPreferences.plist file.
- Log out and log in again, or restart. (This may not be necessary, but be sure to do it if the replacements don't seem to work.)
Voila! From now on the replacement pairs in the TidBITS AutoCorrect Dictionary will be used in favor of the automatic spelling correction feature's potentially incorrect guesses.
(Another tip: If the automatic spelling correction repeatedly changes something you're intending to type, such as replacing "foo" with "of", create a replacement pair in the Language & Text preference pane's Text view that replaces "foo" with "foo". Hopefully that will keep the automatic spelling correction off your case.)
If Things Go Awry -- If you find that adding more than 2,700 entries causes typing performance in Apple Mail or TextEdit to be too slow, you can always go back to the Language & Text preference pane and click the Restore Defaults button to revert to the minimal list that Apple provides.
[Lewis Butler is a longtime Unix system admin, postmaster and Mac geek. He is a frequent contributor to a large number of mailing lists under his "LuKreme" alias.]