0

Amazingly, a year after Lion has been released, iWork still does not support Lion / ML's global text substitution settings.

I use these widely for special technical symbols.

Although global text substitution is not supported in iWork, Keynote and Pages do have their own local text substitution function, which performs the same as the global one, but doesn't use the global settings.

My problem? I have about 100 text substitutions set up in Lion, so entering them in each iWork application would take an age.

Does anyone know a way (e.g. by editing preference files etc.) to transfer all the settings from Lion's text substitution feature into Keynote and Pages?

This would be a huge time saver for me.

3 Answers 3

4
+50

The substitutions for Pages.app are stored in: ~/Library/Preferences/com.apple.iWork.Pages.plist

Specifically they are in Root/kSFWPAutoSubstitutionArrayProperty. The format is a an array containing dictionaries with the keys replace, with and on.

The Global Substitutions are located at ~/Library/Preferences/.GlobalPreferences.plist. Specifically, they are in Root/NSUserReplacementItems. The format, conveniently, is identical.

It's probably possible just to open ~/Library/Preferences/.GlobalPreferences.plist as plain text and copy across what you want into ~/Library/Preferences/com.apple.iWork.Pages.plist.

4
  • This seems to have worked - the replacements are now in Pages. :-) But it has made Pages crash-prone and unstable. :-( Is there a safer way to edit plist files than in a text editor?
    – dan8394
    Aug 16, 2012 at 20:41
  • I know you can open them in Xcode, but that tends to be pretty slow. They are just text though, so I can't really see that being the problem. It seems odd to me that it would be prone to crashing. Perhaps it's because you have so many of them? Maybe see how it performs with fewer substitutions?
    – ratbum
    Aug 16, 2012 at 21:29
  • I found the problem. Smultron - my text editor - was corrupting the files!
    – dan8394
    Aug 17, 2012 at 10:20
  • Oh dear, remind me not to use that. I'm glad you got it sorted, though.
    – ratbum
    Aug 17, 2012 at 15:12
3

I had a similar question. I found a thread on this forum discussing how to move substitutions from one version of OSX to the next. I adapted this solution to moving system substitutions into pages. I wrote a shell script, which could be run with the cron job above.

The script relies mostly on PlistBuddy - a preferences editor supplied with the OS by Apple. You will need to edit it before running so that directories in the script match those on your machine. Other than that, my script is well documented, so I won't discuss further...

#!/bin/bash

# copies text substitution preferences from
# system to pages 
#
# Author: Craig Champlin
# 2/1/2013
#
# Adapted from: http://apple.stackexchange.com/questions/57960/how-can-i-export-text-substitutions-from-lion-for-import-into-mountain-lion
# 
# not robust at all, quick and dirty - use at own risk

# change to preference directory to save typing
cd /Users/Craig/Library/Preferences

# backup preferences for pages
cp com.apple.iWork.Pages.plist com.apple.iWork.Pages.plist.bak

# extract system substitutions to a file
/usr/libexec/PlistBuddy -x -c "Print NSUserReplacementItems" .GlobalPreferences.plist > ./zzzSystemReplacements

# wipe out substitutions in Pages preferences
/usr/libexec/PlistBuddy -c "Delete kSFWPAutoSubstitutionArrayProperty" com.apple.iWork.Pages.plist

# create a new, blank substitutions entry for pages
/usr/libexec/PlistBuddy -c "Add kSFWPAutoSubstitutionArrayProperty array" com.apple.iWork.Pages.plist

# merge exported preferences into pages
/usr/libexec/PlistBuddy -c "Merge zzzSystemReplacements kSFWPAutoSubstitutionArrayProperty" com.apple.iWork.Pages.plist

# visually insure operation completed successfully 
/usr/libexec/PlistBuddy -x -c "Print kSFWPAutoSubstitutionArrayProperty" com.apple.iWork.Pages.plist

As a caveat about using text substitutions in Pages, Pages does not convert the font style like TextEdit does. This means that special characters appear in whatever font you happen to be using. Since most of my substitutions are math symbols and since my default font is Helvetica, my substituted characters usually appear as a dot. I have to change the font style for these characters to Cambria for them to appear correctly.

If you didn't know this, you might assume that the substitution had not worked.

Best of luck to ya!

1

for d in com.apple.iWork.Pages com.apple.iWork.Keynote com.apple.iWork.Numbers; do defaults write $d kSFWPAutoSubstitutionArrayProperty "$(defaults read -g NSUserReplacementItems | sed 's/\\\\/\\/g')"; done

You could also use a text file to configure the substitutions:

(
{on = 1; replace = "..."; with = "…";},
{on = 1; replace = "(c)"; with = "©";}
)

And update them with a script:

t=$(cat ~/Desktop/test.txt)
defaults write -g NSUserReplacementItems "$t"
defaults write com.apple.iWork.Pages kSFWPAutoSubstitutionArrayProperty "$t"
defaults write com.apple.iWork.Numbers kSFWPAutoSubstitutionArrayProperty "$t"
defaults write com.apple.iWork.Keynote kSFWPAutoSubstitutionArrayProperty "$t"

You must log in to answer this question.

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