Changing MacOS keybindings for Home/End keys to behave the same as Windows

Sometimes muscle memory is hard to unlearn. I can’t get used to the Home and End keys on a Mac jumping to the top and end of a file instead of start and end of a line. Yes, I know Cmd-left and Cmd-right do the same thing on a Mac, but pressing Home and having it jump to the top of a file is too much for me to handle when in the middle of editing something in an IDE like Eclipse.

To remap the Home and End keys to behave the same as on Windows, make a dir here:

mkdir ~/Library/KeyBindings

and create a file called DefaultKeyBinding.dict (NOTE: this file must be named exactly as shown to work) containing this content:

{
"\UF729" = "moveToBeginningOfLine:";
"\UF72B" = "moveToEndOfLine:";
"$\UF729" = "moveToBeginningOfLineAndModifySelection:";
"$\UF72B" = "moveToEndOfLineAndModifySelection:";
}

Logoff and log back on again, and the Home and End keys should now work the same as on Windows. (source here)

If this still doesn’t work in Eclipse, it maybe because Line Start and Line End and explicitly mapped to Cmd-left and Cmd-right – these can be changed in Preferences under Keys:

Delete the existing mappings for Home and End and change to the Home and End keys:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.