Where is the Replace/With list stored?

In 10.9 the text replacements are also stored in ~/Library/Dictionaries/CoreDataUbiquitySupport/$USER~*/UserDictionary/local/store/UserDictionary.db. UserDictionary.db is used even if iCloud is disabled and it has precedence over .GlobalPreferences.plist.

If you for example run defaults write -g NSUserDictionaryReplacementItems '({on=1;replace=aa;with=bb;})' and quit and reopen TextEdit, aa is replaced with bb in TextEdit, but the changes are reverted if you open the Text tab of the Keyboard preference pane.

You can change both UserDictionary.db and .GlobalPreferences.plist by using a script like this:

date=$(date +%s)
while read -r replace with; do
  plist+="{on=1;replace=\"$replace\";with=\"$with\";},"
  sql+="INSERT INTO 'ZUSERDICTIONARYENTRY' VALUES($((++i)),1,1,0,0,0,0,$date,NULL,NULL,NULL,NULL,NULL,\"$with\",\"$replace\",NULL);"
done < <(sed 's/\\/\\\\/g;s/"/\\"/g' ~/replacements.txt)
sqlite3 ~/Library/Dictionaries/CoreDataUbiquitySupport/$USER~*/UserDictionary/local/store/UserDictionary.db "delete from ZUSERDICTIONARYENTRY;$sql"
defaults write -g NSUserDictionaryReplacementItems "(${plist%?})"

In 10.8 and earlier versions of OS X the text replacements are stored in the NSUserReplacementItems array (not NSUserDictionaryReplacementItems) in ~/Library/Preferences/.GlobalPreferences.plist.


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-in/guide/mac-help/mchl2a7bd795/mac