is now part of CreativePro.com!

Stand Autocorrect on its ear

12

While digging for something else entirely, I ran across Ann-Marie’s comprehensive post about the Autocorrect feature…and this got me thinking. I’ve always wondered if there is any way to make Autocorrect add special characters like em dashes, trademarks, or even tabs?

If you try to enter a special character into the Autocorrect dialog box, you’ll get an “Entry contains invalid character” message.

I took this into the Gilbert Consulting labs today, and came up with a solution. You can tweak the XML file that contains the Autocorrect list to contain virtually any characters you can imagine. I’ve only tested this in InDesign CS5, but I suspect it would work at least back to CS3 also. Here’s how:

1. Choose Preferences > Autocorrect, and add at least one autocorrect entry to the list entries that appear there. This will cause InDesign to create a copy of the XML file that contains autocorrect entries. This is the copy that we’re going to edit.

2. To locate the correct autocorrect xml file, find your Scripts panel in InDesign. In the panel you’ll see a “User” folder. Right-click or Control-click on this folder, and choose Reveal in Finder/Reveal in Explorer.

3. In the folder that appears, navigate up the folder tree 2 levels. You should see a folder named after your locale (mine is named “en_US”, as in English, United States). In this folder you’ll see a folder named Autocorrect, and in this folder is the XML file we need to edit, named something like “English USA.xml”.

4. Open this xml file in a text editor. Any text editor that can save a file as plain text will do. I use the Oxygen XML Editor, which makes the file easy to read, but any text editor will do.

5. Add whatever “word pair” entries that you wish to the file. Carefully follow the syntax of the existing entries. Notice that all the entries are alphabetic in the file. This isn’t important. You can put all your entries at the top of the file.

6. The “special characters” that we’re concerned about need to be entered as xml “entities”. These appear as an &# followed by a code and then a semicolon. But how do you know the code that needs to be entered for each special character?

Here are a few:

tab x9

em dash x2014

en dash x2013

trademark x2122

To locate other special characters, you can type the character in InDesign, select it, choose File > Export, choose Adobe InDesign Tagged Text, then Verbose and ASCII for the options. Open the text file that results, and you’ll see a code such as <0x00AE> right after the typeface name. You would then enter this code in the xml file as ® (this is the entity for a registered trademark, by the way).

7. Once you’ve made your entries in the xml file, save it as a plain text file. If InDesign is running, you’ll need to quit it and restart it. You may also need to go to Preferences > Autocorrect, and deselect and reselect the “Enable Autocorrect” option.

Now you should be able to use your new Autocorrect entries complete with the special characters you need! If you accidentally screw things up and butcher your .xml file, you can throw it away, and all that you’ll lose will be your custom entries. The word pairs built into InDesign live in a separate file.

Keith Gilbert is a design consultant, developer, educator, speaker, and author. His work has taken him throughout North America, Africa, Europe, and Asia. During his 35+ year career his clients have included Adobe, Apple, Target, Oracle, and the United Nations. He is the author of several popular titles for LinkedIn Learning, Adobe Press, and CreativePro. Find him at gilbertconsulting.com and on Twitter @gilbertconsult
  • Jongware says:

    It’s slightly easier to get the code for a special character than digging into an exported file :)
    Insert it ‘the usual way’ (using your keyboard or the Glyphs panel), then select just that character. The Info panel will show its Unicode value.
    If you are going to call up the Glyph panel anyway, you don’t even have to insert it first. Hover the mouse over the character and a little pop-up hint will show the code as well.

  • Marc Autret says:

    A list of InDesign Special Character codes is provided here:
    https://www.indiscripts.com/post/2009/07/idcs4-special-characters

    @+
    Marc

  • Nadya Miloserdova says:

    Awesome. Absolutely!
    Is there opportunity to change the specified word not only for special symbols by means of autocorrect, but also for a specified picture file?

  • Yes, it does work on CS3. The only differences I found were those below, and they’re really minor (even though the first one might confuse some.

    ? On step 3 I had to navigate up just one level; and
    ? On the same step, the name of the XML file was not abbreviated (mine was “Portuguese Brazilian.xml”).

  • Keith Gilbert says:

    Thank you Jongware and Marc. Yes, the Glyphs panel and Marc’s quick reference are an easier way to get at the Unicode value of characters. Be sure to include the “x” before the value. So if you see 00A9 in the Glyphs panel or the quick reference chart, it would be entered in the xml file as “©” (without the quotes).

  • Keith Gilbert says:

    Gah! WordPress changes character entities to their equivalent characters, of course. So the last sentence of my comment above should read “So if you see 00A9 in the Glyphs panel or the quick reference chart, it would be entered in the xml file as “&#x” followed by “00A9” followed by “;” (without the quotes).

  • Miguel says:

    It also allows, if your “word” begins with something like a parenthesis “(” that the autocorrect entry panel doesn’t let you put in for the word to correct, you can force it here in the XML file. For instance if you want to change “(s” to “(Signed” automatically. Note: you have to type the space after the word before autocorrect kicks in.

  • Rosalind May says:

    This is a fantastic tip: finally I can type em dashes without modifier keys, and real single and double primes for feet and inches. I found that if anything in the XML file wasn’t exactly right, InDesign wouldn’t load the autocorrect dictionary at all. Once I realised that some of my shortcuts used reserved XML characters that needed escaping, things worked just fine. Thank you!

  • Vinny says:

    Hey! Is there any way to prevent Autocorrect for replacing only entire words? Let’s say I want to change “-” to “~”. No problemo with . But that would work only if “-” stands alone.
    “Bla – Bla” will change to “Bla ~ Bla” but “Bla-bla” won’t obviously be affected.
    Any idea? Keep up the good job!^^

  • Vinny says:

    Ooops, should read: No problemo with wordpair misspelled=”-” corrected=”~”

  • Vinny says:

    Hell, I won’t make it… ^^ I’m sure you got the idea…

  • >