oreilly.comSafari Books Online.Conferences.


AddThis Social Bookmark Button

TextEdit's Default Format: RTF... Why?

by Giles Turnbull

RTF stands for Rich Text Format, and in theory is a cross-platform file format for text in word-processed documents.

The format continues to be maintained by Microsoft, but has become widely used on Mac OS X (where it is the default format for the built-in editor, TextEdit) and on other Linux-based systems.

RTF's relative simplicity, human-readable text markup, and cross-platform friendliness have contributed to its success. Even though Word and other MS Office documents now move around from one operating system to another pretty easily thanks to wider support of the Word format, and growth of applications like and AbiWord, RTF remains a reliable way of getting formatted text between users of Linux, Windows, and Mac systems.

Well, that's the theory. In this article, we'll go on a quick tour of RTF--the specification, the history, and the implications for its use in Mac OS X.

But before we go any further, a little diversion.

Try Googling for the phrase "I prefer RTF" and you'll soon spot a common theme linking the results--people often say that because they want to avoid using Word for some reason.

Related Reading

Mac OS X: The Missing Manual
By David Pogue

As a professional writer, I've had my own thoughts about RTF for some years. Before I switched to Mac, I used a series of Windows machines (heck, one job even forced me to use OS/2...) and until I discovered the joys of plain text, I used to make much use of Rich Text Format.

The main reason at the time was not interoperability, but speed. I could open my favorite writing software at the time (Richard Salsbury's wonderful RoughDraft) and start tapping away in an instant. Launching Word was just too great a test of my limited patience.



Making Markup

Correct RTF must meet the criteria of the official RTF specification maintained by Microsoft.

RTF is more helpful than some other formatting markups because it is human-readable, and it was designed to be that way from the outset. It's a text-based format, not a binary one. You can, if you so choose, write RTF markup in a plain text editor (although I can't imagine any circumstances in which that would be a good idea).

But it might help to at least have a look at some raw RTF markup, just so you understand what's going on under the hood.

Take a look at the following screenshot, which shows an RTF document (it just happens to be the README file that came with a recent download of IRC client Colloquy) above, and below the raw RTF markup for the same chunk of text.

RTF output and code side-by-side

You'll instantly notice all the backslashes ("\") in the markup; these are the essential command characters in RTF, just as angle brackets act as tag delimiters in HTML or XML.

Each backslash, and the text that immediately follows it, is a command relating to layout or display of text.

Commands are contained within groups, each group defined by a pair of curly brackets ("{ }").

A valid RTF document is itself a group. Look at the very first markup characters:


The first thing an RTF document has to do is declare itself to be RTF, which is what's happening here.

That all sounds simple enough, but in reality RTF is a bit of a mess. Despite cross-platform ubiquity, and years of development and maintenance, any real-world RTF you're unlucky enough to encounter will be anything but human-readable. It's not structured like XML, and much of the markup is years out of date.

Pages: 1, 2, 3

Next Pagearrow