BigDiver

Dive away, explore the net…

Configure Home/End Key Bidings on Mac OS X

with 7 comments


Hi I feel that this  a prety common request: Bind the Home/End keys to move to the beginning and end of lines respectively.

In Mac OS X (10.5 and 10.6) some applications use the Cmd-Rigt and Cmd-Left to perform these actions but, call me old fashioned, I like to use Home and End instead.

It is actually very easy to change the Cocoa Key bindings for any user under Mac OS. Just follow these steps:

  1. Create a file called DefaultKeyBinding.dict in ~/Library/KeyBindings directory
    mkdir ~/Library/KeyBindings
    cd ~/Library/KeyBindings
    touch DefaultKeyBinding.dict
  2. Edit your DefaultKeyBinding.dict file so it contains:
    {
    /* home */
    "\UF729"  = "moveToBeginningOfLine:";
    "$\UF729" = "moveToBeginningOfLineAndModifySelection:";
    
    /* Cmd-Left */
    "@\UF702"  = "moveToBeginningOfLine:";
    "$@\UF702" = "moveToBeginningOfLineAndModifySelection:";
    
    /* Cmd-Right */
    "@\UF703"  = "moveToEndOfLine:";
    "$@\UF703" = "moveToEndOfLineAndModifySelection:";
    
    /* end */
    "\UF72B"  = "moveToEndOfLine:";
    "$\UF72B" = "moveToEndOfLineAndModifySelection:";
    
    /* page up/down */
    "\UF72C"  = "pageUp:";
    "\UF72D"  = "pageDown:";
    }
  3. Restart the Cocoa Application.

This example works very well with TextMate.

In order to bind other keys you need to find their Scan code, and you can use the following modifiers
For more information please check this article

Written by bigdiver

September 11, 2009 at 7:26 pm

7 Responses

Subscribe to comments with RSS.

  1. [...] BigDiver Se você gostou deste artigo, compartilhe com outras pessoas. Tags: dicas [...]

  2. What are the equivalent of “Home” & “End” keys on a Mac?…

    On a full-size keyboard, they would be the ‘home’ and ‘end’ key, sometimes indicated by a diagonal arrow symbols on an international keyboard. On a smaller keyboard, such as the wireless, or on portables, you can use fn- left arrow for home and fn-…

    Quora

    October 28, 2010 at 12:12 pm

  3. what does ~ mean in your path ~/Library/KeyBindings ? If I’m looking up how to get those keys to work you’d think I have the most basic problems on a mac to start with and then using ~ to fill in some directory that first time users have no clue what it is not so helpful.

    Ivan

    April 22, 2012 at 11:36 pm

  4. okay hey, apparently ive done this trick on my mac pro but forgot and ive used my mbp for quite some time and use the cmd+left and cmd+right A LOT. however i cant get my mac pro to register those commands. Is there an easy way to reset every binding or something?

    thanks a lot.

    syonidism

    April 25, 2012 at 6:50 pm

  5. I just applied this little “patch” and it works perfectly fine! I just want to thank you, it’s great!!

    Mark

    May 10, 2012 at 8:39 pm


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.