Thoughtful, detailed coverage of the Mac, iPhone, and iPad, plus the best-selling Take Control ebooks.

 

 

Pick an apple! 
 
Monitor Network Throughput with VirusBarrier X6

Concerned about how much data is coming into or leaving your Mac? Try VirusBarrier X6's network monitoring tools, which include a Traffic window, a standalone Traffic Monitor application, and even a screensaver that displays real-time traffic information.

Visit Intego

 

 

Related Articles

 

 

Improve Snow Leopard's Autocorrection Capabilities

Send Article to a Friend

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:

<dict>
    <key>on</key>
    <integer>1</integer>
    <key>replace</key>
    <string>wth</string>
    <key>with</key>
    <string>with</string>
</dict>

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.)

  1. Open the Language & Text preference pane.
  2. Click the Text button to switch to the Text view.
  3. Click the + button and add a new replacement. I suggest "teh" and "the".
  4. Open the reformatted TidBITS AutoCorrect Dictionary in BBEdit or TextWrangler, select all (Command-A), and copy the text to the clipboard.
  5. In BBEdit, choose File > Open Hidden.
  6. Navigate to your home folder, then Library, then Preferences and select the .GlobalPreferences.plist file.
  7. In that file, find the replacement pair you added (search for "teh").
  8. Select the entire dictionary entry (from dict to /dict).
  9. Paste the contents of the linked file from before over the "teh" dictionary entry.
  10. Save the .GlobalPreferences.plist file.
  11. 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.]

 

New for iOS 8: TextExpander 3 with custom keyboard.
Set up short abbreviations which expand to larger bits of text,
such as "Tx" for "TextExpander". With the new custom keyboard,
you can expand abbreviations in any app, including Safari and
Mail. <http://smle.us/tetouch3-tb>
 

Comments about Improve Snow Leopard's Autocorrection Capabilities
(Comments are closed.)

Chris Devers and I discussed this on twitter for an hour or so and he came up with this:

defaults write -g NSUserReplacementItems -array-add '{ "on" = 1;
"replace" = "macgyver"; "with" = "MacGyver";}'

However, this method adds the items to the list unchecked (disabled). However, it doesn't require a text editor and is easily scriptable. If anyone figures out how to add the items so they are actually enabled, let us know.
Louis-Jean Teitelbaum  2009-09-18 10:23
The one in "on" = 1 is misinterpreted as a string, instead it should be an integer or a boolean.

Resorting to XML notation works better:
(woops, it seems I'm having trouble with the comment form that kills angled brackets -- if necessary, check http://pastie.org/621995).

defaults write -g NSUserReplacementItems -array-add '&lt;dict&gt;&lt;key&gt;on&lt;/key&gt;&lt;integer&gt;1&lt;/integer&gt;&lt;key&gt;replace&lt;/key&gt;&lt;string&gt;macgyver&lt;/string&gt;&lt;key&gt;with&lt;/key&gt;&lt;string&gt;MacGyver&lt;/string&gt;&lt;/dict&gt;'


For the record, I just copied the .GlobalPreferences.plist file's format.
Jim Gagne  2009-09-21 19:44
I just played with autocorrection, and it leaves a lot to be desired. As you say, it's too hard to add new autocorrection entries. I wish the Snow Leopard facility worked like Spell Catcher (www.rainmakerinc.com).

When Spell Catcher finds an error, it puts up a dialog with suggested fixes. You can add the word to the dictionary or enter a new autocorrect or abbreviation entry. There are keyboard shortcuts for everything. It's INTELLIGENT.

Rainmaker says it works in Snow Leopard, but for me it keeps turning itself off. Because it's an Input Source, it works only in 32-bit programs. Needs work. Maybe they could turn it into a better front end for the new Snow Leopard feature. Better idea: Apple should buy it.

Finally, why in the world did Apple put this in the Global Preferences file? Sounds like an invitation to disaster.
Jim Gagne  2009-09-23 16:01
I've played with this some more. Spell Catcher DOES work just fine in Snow Leopard. It just needs a couple of tweaks, described in the following article:

http://www.rainmakerinc.com/kb/index.php?article=97
theMaesu  2009-09-22 01:29
On my Swiss-German Snow Leopard, Apple Mail doesn't expand my text substitution. It works in TextEdit though.

Does anyone using a localized system discover similar problems?
One other note I just discovered thanks to a question on this article; the learned words for the spell checking are stored in a plain text file located at

~/Library/Spelling/LocalDictionary

In OS X 10.5, this file was NOT a plain text file. If you would like to get your old dictionary entries out of the old file (~/Library/Spelling/en) you can run this shell command:

perl -pe 's/\000/\n/g' /path/to/old/en >> ~/Library/Spelling/LocalDictionary

Make backups first, of course.

I'd share mine, but it consists largely of names of people I know and obscenities :)

If you use multiple languages, you likely have multiple files, and if your primary language is not English, the old file will not be named 'en'.
Adam Engst  An apple icon for a TidBITS Staffer 2009-09-23 06:24
Hey, thanks for the sleuthing - now if someone can figure out how to sync this with Firefox's dictionary, that would be great.
Firefox has a dictionary?
Adam Engst  An apple icon for a TidBITS Staffer 2009-09-23 09:23
Yeah, it does inline spell checking in text areas via the red underlines too, but it's a separate dictionary from Mac OS X, and I've not figured out how to access it yet. As a result, it doesn't know any of my learned words and is basically useless.
Your wish, my command.

cat ~/Library/Spelling/LocalDictionary >> ~/Library/Application\ Support/Firefox/Profiles/.default/persdict.dat

Looks like it works. Despite being a .dat file the Firefox file is also a straight ASCII file.
David Travis  2009-09-23 02:18
Thanks for this useful resource. I've edited the file to change the more egregious examples of American English to the Queen's English. If you want a UK English version of the dictionary, you can get it from here: http://dl.getdropbox.com/u/421018/AutoCorrectUK.zip
Adam Engst  An apple icon for a TidBITS Staffer 2009-09-23 06:24
Thanks for tweaking this for the Queen's English! You have our vote for a knighthood.
Harlan   2009-10-03 11:13
About BBeditor or Textwrangler
Could I use XCode for this?
Sorry if this seems ignorant I'm just learning about this side of the mac... And trying to teach myself.
You can simply use TextEdit if you want. Go to File > Open... and then perform the keyboard shortcut shift+command+. (period)

That shortcut will enable you to view invisible files.
Adam Engst  An apple icon for a TidBITS Staffer 2009-10-12 14:38
No, you'll need to use TextWrangler (free) or BBEdit (not free) because the file is a compressed plist. TextEdit won't work either, despite the trick to be able to open invisible files, because it can't handle compressed plist files.