Pages: Using key bindings for text selection

Posted by Pierre Igot in: Pages
February 6th, 2005 • 5:38 am

Yesterday, I wrote an item about options for text selection in Pages. This prompted a reader to write to me about key bindings in Cocoa applications and how they could be used to achieve some of the things that I wanted to achieve.

He also provided me with a ready-made file called DefaultKeyBinding.dict that I just had to install in a new folder called “KeyBindings” inside my home library folder. After that, I just needed to quit and restart Pages — et voilà.

I can now use control-P to select the current paragraph and control-L to select the current line (i.e. the paragraph/line where the cursor currently is).

The key bindings file that the reader sent me is a simple file that can be edited with a text editor or with PropertyListEditor (the utility included in Apple’s Developer tools for Mac OS X). Here is what it contains:


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist SYSTEM 
"file://localhost/System/Library/DTDs/PropertyList.dtd">
<plist version="0.9">
<dict>
	<key></key>
	<string>complete:</string>
	<key>^</key>
	<string>deleteWordBackward:</string>
	<key>^<</key>
	<string>moveToBeginningOfDocument:</string>
	<key>^></key>
	<string>moveToEndOfDocument:</string>
	<key>^b</key>
	<string>moveWordBackward:</string>
	<key>^d</key>
	<string>deleteWordForward:</string>
	<key>^f</key>
	<string>moveWordForward:</string>
	<key>^h</key>
	<string>deleteWordBackward:</string>
	<key>^l</key>
	<string>selectLine:</string>
	<key>^p</key>
	<string>selectParagraph:</string>
	<key>^v</key>
	<string>pageUp:</string>
	<key>^</key>
	<string>deleteWordBackward:</string>
</dict>
</plist>

He also sent me a different sample file with a more comprehensive list of all the bindings that can be added. The other file also contains a warning about editing the key binding list in a text editor. It sounds like it’s a much better idea to edit it with PropertyListEditor. (It looks like there are actually two different possible file formats for key bindings — the XML format, used in the file above, and a plain text format.)

Here are a couple more pages about key bindings in Mac OS X.

The beauty of this is of course that it is something that has built-in support in Mac OS X, and works across all Cocoa applications. In other words, the same keyboard shortcuts can be used in other Cocoa applications such as Mail, TextEdit, etc.

In fact, I clearly remember reading about this particular Mac OS X feature a long time ago — but at the time it had limited interest for me, since many of the applications that I was using were not Cocoa applications.

I still use a number of Carbon applications, including, most notably, BBEdit as my main text editor — but now, with Mail being my e-mail client and Pages quickly becoming my preferred word processor, these key bindings are becoming very useful indeed.

I still believe that the user should not be required to customize his system environment in order to have easy access to quick shortcuts for selecting lines and paragraphs of text in Pages — but until Pages includes something that does not require a customized DefaultKeyBinding.dict file, this will do quite well. (Also, having some mouse-based shortcuts for text selection wouldn’t hurt either.)

(Key bindings can also consist of multi-keystroke shortcuts.)

Thanks to S.A.!


One Response to “Pages: Using key bindings for text selection”

  1. Warren Beck says:

    Thanks very much for posting this information, Pierre. This is just another reason why I make it a point to read the Betalogue.

    Now, it would be nice if Apple would provide this sort of technical information on Pages in a central location. I would like to know, for instance, about the details of the XML file format that Pages uses.

Leave a Reply

Comments are closed.