By default, the HOME and END keys on macOS navigate to the beginning and ending of the document. If you work with code editors, you are not used to this behavior. In this article, you read how to change it.

Make HOME and END keys go to the beginning and ending of a line in macOS.

This method changes the behavior like this:

KeyOld behaviorNew behavior
HOMEBeginning of documentBeginning of line
ENDEnd of documentEnd of line
SHIFT + HOMESelect to beginning of documentSelect to beginning of line
SHIFT + ENDSelect to end of documentSelect to end of line

How to change it

Create or edit this file:

~/Library/KeyBindings/DefaultKeyBinding.dict

Add this code:

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

Save the file. I needed to logout and login again to apply the changes.

Compatibility

I tested this on MacOS Ventura and it works in Apple Pages and iaWriter. Be careful when remapping keys. The wrong settings can make your computer not working properly anymore!

Written by Loek van den Ouweland on 2025-02-05.
Questions regarding this artice? You can send them to the address below.