The default shortcuts for moving to beginning or end of (wrapped) lines are ⌘← and ⌘→. ⌥↑ and ⌥↓ or ⌃A and ⌃E move to the beginning or end of unwrapped lines (or paragraphs). ⌥← and ⌥→ move backwards/forward by words, and all of these are compatible with holding Shift to select during the corresponding moves.
You could remap home and end by creating ~/Library/KeyBindings/
and saving a property list like this as DefaultKeyBinding.dict
:
{
"\UF729" = moveToBeginningOfLine:; // home
"\UF72B" = moveToEndOfLine:; // end
"$\UF729" = moveToBeginningOfLineAndModifySelection:; // shift-home
"$\UF72B" = moveToEndOfLineAndModifySelection:; // shift-end
}
Most of the keybindings for editing text in OS X are defined in /System/Library/Frameworks/AppKit.framework/Resources/StandardKeyBinding.dict
.
Applying changes requires reopening applications. DefaultKeyBinding.dict is ignored by some old versions of Xcode (works with latest version 6.3.1), Terminal, and many cross-platform applications.
See Cocoa Text System and my website for more information about the customizable keybindings.
Terminal's keybindings can be customized in Preferences > Settings > Keyboard. \033OH
moves to the beginning of a line and \033OF
to the end of a line.
In Eclipse, key bindings should be modified in Preferences > General > Keys. You need to modify default bindings for commands Line Start and Line End (replace ⌘← by ↖ and ⌘→ by ↘). For selection to work, also modify Select Line Start and Select Line End.
PS: You may need to logout and login again for the ~/Library/KeyBindings/DefaultKeyBinding.dict
change to take effect.
KeyMap4MacBook can actually do this. As I told in the question, the problem is Windows and Mac OSX interpret Home and End differently. So what I needed was an app that allowed me to have different mappings for different apps (Windows is in VM Ware or Parallels, which are apps)
KeyMap4MacBook allows to have different key mappings for the Mac and different ones for VMs / Remote Desktops:
Best Answer
One option is to create
~/Library/KeyBindings/
and save a property list like this as~/Library/KeyBindings/DefaultKeyBinding.dict
:Quit and reopen applications to apply the changes. Note that
DefaultKeyBinding.dict
is not supported by some applications like Xcode or Firefox.In Terminal you can assign home (↖) to control-a and end (↘) to control-e from Preferences > Settings > Keyboard. That will leave you with no key combinations to scroll to the top or bottom of a window though.
It might be easier to just use the default keybindings. In most native text views: