Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have just copied a large amount of text from an application and it is already formatted. Is it possible to apply a style to all text that has the same formatting?

enter image description here

For example, the commit comments ("ADDED: ") are always Lucidia Grande size 12. I would like to save that as a style and apply that to every commit comment (identified by the same formatting) in the document.

Is this even possible? Is there something similar or some kind of shortcut that would be better than applying the style to every comment (I have 500 commits in this document)?

share|improve this question
I doubt it will work, and I cannot test, but: what if you first define all the styles you need (using a small part of the text), and then paste all text? – Arjan Nov 7 '09 at 11:16

By hand, your best bet would be to use the multiple select feature. Go through and select the text you want, holding down the command key. This should select each piece separately Then, once all your text is selected, apply the style using the styles tray.

You might prefer some automation. You could try using AppleScript to copy your document to a new correctly styled document. Here's one example I found. Otherwise, the underlying format to Pages documents is XML. You may be able to use an XML transformation language like XSLT to add in the appropriate style declaration where it belongs. Or you could use another language like Python/Perl with some carefully crafted regexes. Be careful though, messing with the underlying XML is considered dangerous.

You may also want to look out for a more systematic error. It sounds like you have content already, and you want to apply a certain kind of formatting for it. Pages may not be the best tool for what you want to do. Instead consider other options for storing and manipulating the data you have. XML or another hierarchical format would work best. That way you can store your content demarcated for each piece: <Title> <Comment> etc. You can then use something to translate this content to a desired style, if you went with XML, you'd use XSLT. Using XSLT, you could translate it to RTF, HTML, or just about anything. If you went with HTML, for instance, you could easily apply a CSS to manage your styles.

share|improve this answer
But I don't want to! I am quite certain that Word 2007 has a similar feature. I cannot put all this data into XML or another format. It is already text that is already in Pages. – Josh Hunt Aug 11 '09 at 20:58
Pages is not feature-for-feature a clone of Word 2007. If you need the feature, you should honestly use Word. Given your situation, this answer tells you what to do without MS Word. – jweede Aug 11 '09 at 21:39
I know it isn't a clone of Word 2007, and I am not trying to say it should be either, but I thought that Pages might have a similar feature. – Josh Hunt Aug 12 '09 at 1:26
Sorry. It doesn't. :( – jweede Aug 12 '09 at 11:26

You can't.

share|improve this answer
yep. Not a built-in feature. – jweede Apr 12 '10 at 13:44

The simplest way to do this is to export your file to .doc format (Word file), apply styles in Word (even if they're not your final styles) then import back into Pages. The style declarations will remain intact.

I frequently perform this dance when converting documents to epub (epub is a pages export option). If possible, paste into Word in the first place to avoid the first export.

share|improve this answer

Bean (a free RTF editor like TextEdit) also has an action for selecting text by style.

share|improve this answer

You must log in to answer this question.

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