Configure Home/End Key Bidings on Mac OS X
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:
- Create a file called DefaultKeyBinding.dict in ~/Library/KeyBindings directory
mkdir ~/Library/KeyBindings cd ~/Library/KeyBindings touch DefaultKeyBinding.dict
- 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:"; } - 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
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.
Hi Ivan. The “tilde” is a symbol for your “home directory” on your computer, which is the default folder in your file system where you store your personal files. For more info, see http://en.wikipedia.org/wiki/Tilde#Directories_and_URLs
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.
I am still not getting it. Can you provide point by point instructions for activating Home/End keys, i would appreciate it. They do work in Outlook by using ALT + left/right arrows as someone pointed out but it’s not the simple as Home/End. Thanks for your help (I hope). I am using Mt. Lion with Office for Mac and a Microsoft 3000 keyboard. PS: the Genius bar is clueless about this feature.
Hi Pete. Referring to steps one through three in the original post, you can do Step 1 using the Terminal application and Step 2 using TextEdit. (Both of those programs come standard on the Mac.)
I just applied this little “patch” and it works perfectly fine! I just want to thank you, it’s great!!
Thank you for the tip, worked perfectly for me in Sublime Text 2 on Mountain Lion.
Works great on Mountain Lion + my Microsoft ergo 4000 keyboard. Thank you!
You just made me a very happy person. I found this while trying to solve the same problem by modifying a keyboard layout. This is much easier though.
Thanks!
Thank you!