3

Under System Preferences/Keyboard/Text, you can enter a list of "spelling corrections" which can easily act as a macro-replacement for quick typing.

It is easy to enter them one-by-one, but is there a way to mass-load a long list of mappings?

Say from some kind of text file like a .csv file? Or could I potentially write something in AppleScript to do this?

Also, is there a limit to how many mappings I make?

I'm thinking on the order of thousands.

4

The settings are stored in ~/Library/Preferences/.GlobalPreferences.plist in the NSUserDictionaryReplacementItems array in 10.9 and in the NSUserReplacementItems array in 10.8 and earlier. The format of the array has not changed, so the commands below should work in 10.8 and earlier versions of OS X if you replace NSUserDictionaryReplacementItems with NSUserReplacementItems.

Print the current settings:

defaults read -g NSUserDictionaryReplacementItems

Add one setting:

defaults write -g NSUserDictionaryReplacementItems -array-add '{on=1;replace=cmd;with="⌘";}'

Replace all settings:

defaults write -g NSUserDictionaryReplacementItems '(
{on=1;replace=cmd;with="⌘";},
{on=1;replace=opt;with="⌥";}
)'

Print the current settings as XML:

defaults read -g NSUserDictionaryReplacementItems | plutil -convert xml1 - -o -

Replace all settings:

amp() { local x=${1//&/&amp; }; x=${x//</&lt; }; printf %s "${x//>/&gt; }"; }
out='<array>'
while IFS= read -r l; do
  out+="<dict><key>on</key><integer>1</integer><key>replace</key><string>$(amp "${l%% *}")</string><key>with</key><string>$(amp "${l#* }")</string></dict>"
done <<< 'cmd ⌘
opt ⌥'
defaults write -g NSUserDictionaryReplacementItems "$out</array>"

You can apply changes made with defaults by quitting and reopening applications.

  • 1
    Awesome. Just to add on: I think it may be possible to put the defaults write into a file that you could then save and re-use later on. I would definitely start with fewer than a thousand at first, and make sure that the process is working as you'd expect. IIRC, these sync via iCloud to iOS from Mavericks. No idea if there is any practical limit to how many you can make. – TJ Luoma Dec 3 '13 at 7:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .