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]
Share
Categories
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
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.
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.
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 Permalink rate up rate down ReplyThere 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"
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 Permalink rate up rate down ReplyJeremy,
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.
Now that I read it again, maybe you meant that. Oh, well.
March 13 2006 at 9:27 PM Report abuse Permalink rate up rate down ReplyFWIW, 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 Permalink rate up rate down ReplyI'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.
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 Permalink rate up rate down ReplyHot Apps on TUAW
Deals of the Day
more deals- Refurb Apple MacBook Air Laptops: 12" 64GB SSD for $699 + free shipping
- JVC Motion Sensing Clock Radio with Dual iPod Docks for $55 + free shipping
- Apple iPhone Headset with Mic for $4 + $2 s&h
- miFrame Picture Frame Dock for iPad for $64 + $8 s&h
- Refurb Apple iPod nano 8GB MP3 Player for $99 + free shipping, 16GB for $119
- Hannspree Apple-Shaped 28" 1080p LCD HDTV for $270 + free shipping
Software Updates
more updates- EFI Firmware Update brings Lion Internet Recovery to 2010-model Macs
- OS X Lion 10.7.3 released with Safari 5.1.3, Wi-Fi bug fix
- Aperture updated to 3.2.2, addresses Photo Stream issue
- Apple updates Keynote to address Lion issues
- Google Search app gets new look on iPad
- Apple releases Apple TV Software Update 4.4.3



15 Comments