From Windows to Mac: A Home Run

I had no idea how ingrained it was for me to hit the Home and End keys, expecting them to take me to the beginning or the end of the line, respectively, until I tried to work on my new Mac. There, the default behavior for Home & End is to go to the top or bottom of the document. Ugh! Fortunately, I didn’t have to live with that bad behavior long.

First, I found an article on www.lifehacker.com, explaining specifically how to remap the Home and End keys, for any cocoa-based application, which most Mac apps are, apparently.

Searching further, I then found an excellent article on www.lsmason.com that went deeper into the details and offered suggestions for other remappings.

As described by both articles, I had to first create a KeyBindings folder in my Library folder (not to be confused with the existing Keyboard Layouts folder). I then created a text file called DefaultKeyBinding.dict within the KeyBindings folder. My DefaultKeyBinding.dict file looks like this:

{
"UF729"   = "moveToBeginningOfLine:";
/* Home */

"UF72B"   = "moveToEndOfLine:";
/* End */

"^UF729"  = "moveToBeginningOfDocument:";
/* Ctrl-Home */

"^UF72B"  = "moveToEndOfDocument:";
/* Ctrl-End */

"$UF729"  = "moveToBeginningOfLineAndModifySelection:";
/* Shift-Home */

"$UF72B"  = "moveToEndOfLineAndModifySelection:";
/* Shift-End  */

"$^UF729" = "moveToBeginningOfDocumentAndModifySelection:";
"$^UF72B" = "moveToEndOfDocumentAndModifySelection:";

"^UF702"  = "moveWordBackward:";
/* Ctrl-Left arrow */

"^UF703"  = "moveWordForward:";
/* Ctrl-Right arrow */

"$^UF702" = "moveWordBackwardAndModifySelection:";
/* Ctrl-Shift-Left arrow */

"$^UF703" = "moveWordForwardAndModifySelection:";
/* Ctrl-Shift-Right arrow */

"UF72C"   = "pageUp:";
"UF72D"   = "pageDown:";

"^z"       = "undo:";
"^x"       = "cut:";
"^v"       = "paste:";
"^c"       = "copy:";

"$UF706"  = "capitalizeWord";
/* Shift F3 */
}

After restarting the Mac, all was well, except that the Ctrl-Left arrow and Ctrl-Right arrow bindings didn’t work for me, because they were defined as hot keys for Spaces. Not having found Spaces to be all that useful anyway, I simply disabled it, though I suppose I could have reassigned those hot keys.

Related articles:

Comments

  1. BTW, if moveWordForwardAndModifySelection doesn’t work for you as advertised, you are not alone. It appears to be a bug in OS X (see http://lists.macosforge.org/pipermail/webkit-unassigned/2007-December/057362.html)

  2. you are missing the backslashes in the quoted code

Post a Comment


Your email is never published nor shared. Required fields are marked *



© 2006-2007 Maxim Software Corp.  All rights reserved.