How can I export text substitutions from Lion for import into Mountain Lion

Thanks to Sacrilicious identifying the actual file/key where the data is stored, I figured out how to copy the whole thing with a few Terminal commands.

Make sure you don't have System Preferences open while doing this, or it may not work!

  1. On your old install, run /usr/libexec/PlistBuddy -x -c "Print NSUserReplacementItems" ~/Library/Preferences/.GlobalPreferences.plist > backup.plist
    • This saves the substitutions to the backup.plist file in whatever directory you ran that command from (by default, your home directory).
  2. Copy that backup.plist file to your new install (I recommend your home directory for simplicity).
  3. On the new install, run /usr/libexec/PlistBuddy -c "Delete NSUserReplacementItems" ~/Library/Preferences/.GlobalPreferences.plist, then run /usr/libexec/PlistBuddy -c "Add NSUserReplacementItems array" ~/Library/Preferences/.GlobalPreferences.plist
    • This wipes the default substitution list and creates a new blank one.
  4. Again on the new install, run /usr/libexec/PlistBuddy -c "Merge /PATH-TO-BACKUP/backup.plist NSUserReplacementItems" ~/Library/Preferences/.GlobalPreferences.plist, first replacing the /PATH-TO-BACKUP/backup.plist part with the actual path to wherever you saved the backup file.

That should do it. Open System Preferences to double check, but you should have an identical copy of your text substitutions on your new install.


Programmatically speaking, each substitution is a dictionary written to the NSUserReplacementItems array at the root of the ~/Library/Preferences/.GlobalPreferences.plist file.

I'm not able to think of a simple way to move data, even with Xcode's Property List Editor, from 1. an invisible file 2. in a hidden folder 3. to a specific part of the new systems file. To get you started, you can read them all with defaults read .GlobalPreferences NSUserReplacementItems or, if you want to just pull one(the first I'm seeing that I just customized in Lion is located at index #15, therefore): /usr/libexec/PlistBuddy -c "Print :NSUserReplacementItems:15" ~/Library/Preferences/.GlobalPreferences.plist which would return something like this:

Dict {
replace = bIg 
with = BigBabyBuggyBumpers
on = 1
}

And then writing the stuff back could be done in any scripting language that speaks apple's xml, or piecemeal with the trio of:

/usr/libexec/PlistBuddy -c 'Add :NSUserReplacementItems:16:on integer 1' ~/Library/Preferences/.GlobalPreferences.plist (which turns the checkbox on)

/usr/libexec/PlistBuddy -c 'Add :NSUserReplacementItems:16:replace string "bIg"' ~/Library/Preferences/.GlobalPreferences.plist

/usr/libexec/PlistBuddy -c 'Add :NSUserReplacementItems:16:with string "BigBabyBuggyBumpers"' ~/Library/Preferences/.GlobalPreferences.plist

I'll tweet it out, someone probably has the easier way and can chime in or build on this.


I found an easier way to do it.

Use these steps to export your existing text substitutions: - Open System Preferences > Keyboard > Text.

  • Select the shortcuts you want to export. If you want to export all of your text substitutions, select one of them, then choose Select All from the Edit menu.

  • Drag the selected shortcuts to the desktop. This creates a file name Text Substitutions.plist that contains the substitutions you selected.

  • Close the System Preferences window.

Use these steps to import the plist file you created in another user account: - Copy the plist file you previously created to the /Users/Shared/ folder, or to an external drive.

  • Log in as the user account where you want to use these text substitutions.

  • Open System Preferences > Keyboard > Text.

  • Drag the Text Substitutions.plist file to the area of the System Preferences window where the text substitutions are shown (under Replace or With).

  • Close the System Preferences window.

source: https://support.apple.com/en-us/HT204006