Skip to Content

Remapping Key Combinations

Some people may think I am pro-*nix, but actually I really just like getting information out there for all our readers. Today I came across a great tip on Switch about Windows-like key bindings. If you don't dig the way Apple has the start and end key combos mapped in OS X, you can change them by creating the file ~/Library/KeyBindings/DefaultKeyBinding.dict with the following contents:

/* ~/Library/KeyBindings/DefaultKeyBinding.dict - Home/End keys more like Windows */
{
"\UF729" = "moveToBeginningOfLine:"; /* home */
"\UF72B" = "moveToEndOfLine:"; /* end */
"$\UF729" = "moveToBeginningOfLineAndModifySelection:"; /* shift home */
"$\UF72B" = "moveToEndOfLineAndModifySelection:"; /* shift end */
"^\UF729" = "moveToBeginningOfDocument:"; /* control home */
"^\UF72B" = "moveToEndOfDocument:";/* control end */
}


I personally tested this key binding hack in 10.4.4 and it does work. To test it be sure to quit out of your text application first. Also note that you will have to create a KeyBindings/ directory in your ~/Library/ because it is not there by default. To reverse the key bindings back to normal, just delete the DefaultKeyBinding.dict file you created and restart your text application. If there is a simpler GUI way to create these modifications please post about it in the comments for our readers.

If on the other hand you live in Terminal like me, the start of line and end of line key bindings are Control-A and Control-E respectively. This should feel comfortable to people accustomed to the normal Emacs mode in a shell in other *nix based operating systems.

[via Switch and comments on Ask Slashdot]

Some people may think I am pro-*nix, but actually I really just like getting information out there for all our readers. Today I came across...
 

Add a Comment

*0 / 3000 Character Maximum

15 Comments

Filter by:
won

Part of the reason I as a Mac user don't use Home / End as on Windows is that the default text shortcuts already have this feature in the form of Command-right arrow and Command-left arrow.

Furthermore (and perhaps more useful), on Macs, in text fields, up arrow takes you to the beginning of a line and down arrow takes you to the end.

April 05 2006 at 10:25 AM Report abuse rate up rate down Reply
Percy

I added these two lines to mine:

"^$UF729" = "moveToBeginningOfDocumentAndModifySelection:"; /* control shift home */
"^$UF72B" = "moveToEndOfDocumentAndModifySelection:";/* control shift end */


This adds Ctrl+Shift+Home/End, since without these two lines it just moves the cursor to top/bottom without selecting as expected.

April 05 2006 at 10:22 AM Report abuse rate up rate down Reply
Z

Thanks go out to Jonathan for sharing DoubleCommand as it managed me to do the same without editing any file. By the way, i missed this "feature" of Windows!

March 14 2006 at 5:09 PM Report abuse rate up rate down Reply
Jacob Rus

There are actually a ton of cool things to be done with the Cocoa Text System. I've written extensively about it here:

http://hcs.harvard.edu/~jrus/Site/Cocoa%20Text%20System.html

Also, I made a list of the supported actions here:

http://hcs.harvard.edu/~jrus/Site/selectors.html

One of my favorite things to do:

defaults write -g NSRepeatCountBinding -string "^u"

March 14 2006 at 4:30 AM Report abuse rate up rate down Reply
MIchael S.

I don't think the Windows Home/End behaviour is strange at all. Scrolling to the beginning/end of the document--and not even moving the cursor!--that's weird.

March 14 2006 at 3:04 AM Report abuse rate up rate down Reply
nt

Jeremy,

And I've never been able to figure out why End should go to the end of the document.. I think my ratio of needing to go to the end of the line vs end of the document is like 5603549465 to 1.

tomayto, tomahto.

March 13 2006 at 9:40 PM Report abuse rate up rate down Reply
Wevah

Now that I read it again, maybe you meant that. Oh, well.

March 13 2006 at 9:27 PM Report abuse rate up rate down Reply
Wevah

FWIW, control-A/control-E also work in cocoa text fields/text views, and even a few Carbon applications like BBEdit/TextWrangler.

March 13 2006 at 9:21 PM Report abuse rate up rate down Reply
Jeremy

I've never been able to figure out why someone would ever in a million years think that "home" and "end" keys should move to the beginning and end of a line, or why they would want to replicate this completely stupid and broken behavior of Windows.

March 13 2006 at 7:40 PM Report abuse rate up rate down Reply
Jonathan

You could also download DoubleCommand (http://doublecommand.sourceforge.net) which does this with a GUI along with a whole bunch of other key bindings that can be changed.

March 13 2006 at 7:27 PM Report abuse rate up rate down Reply
Buy an ad here

Hot Apps on TUAW

Tweets

© 2012 AOL Inc. All Rights Reserved.