Michael Kovacs' photos More of Michael Kovacs' photos
Recommend Me Cable Car Software logo

Friday, June 09, 2006

Page Up/Page Down and moving the caret in Textmate

For rails development TextMate has been the editor of choice for anyone using a mac because of the numerous features it has built in for rails. My #1 complaint with the editor has been the page up/page down behavior, namely the caret would never move when you performed a page up or down. I've been living with this deficiency for awhile now but decided to figure out how to fix this problem.

If you checkout the TextMate docs in section 16.3 "Text Move / Edit Actions", you'll see:

The master set of keys can be augmented by ~/Library/‍KeyBindings/‍DefaultKeyBinding.dict. The most common request with respect to key bindings is to have page up/down move the caret, and have home/end go to the beginning and end of the line. This article shows how this can be done.

You then arrive and discover that the article makes mention of the common request made to have the caret move with a page up/down and then immediately discusses that the article will provide an example for windows switchers where the home/end keys move to the beginning/end of the line respectively. Luckily if you read the article closely enough you'll see that he also provides an example for page up/down.

Turns out that the default key bindings in OSX do not move the caret on a page up/down. So the quick fix is to make sure that you create a blank file (unless you have already created a key binding file, then skip this step and just add the bindings below) called: ~/Library/KeyBindings/DefaultKeyBinding.dict

Then simply add:

/* page up/down */
"\UF72C" = "pageUp:";
"\UF72D" = "pageDown:";

to that file. Save it. Restart TextMate and voila! when you page up/down the caret will move with the scrolling activity.

Hi michael - this is David, I introduced myself to you at the SF Ruby conference. Just wanted to drop a note here and say hi, also if you explore using Ruby/Lucene/Ferret and other search tools I'd love to hear about your experiences.

My e-mail is david@davidyang.net
sweet! thanks, this worked perfectly.

Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?