Skip to content

Instantly share code, notes, and snippets.

@julienma
Created February 18, 2020 13:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save julienma/8ef8a8a8521a656ccdc9a70d179900b4 to your computer and use it in GitHub Desktop.
Save julienma/8ef8a8a8521a656ccdc9a70d179900b4 to your computer and use it in GitHub Desktop.
Enable Home/End keys on macOS to behave like Windows

Source: https://damieng.com/blog/2015/04/24/make-home-end-keys-behave-like-windows-on-mac-os-x

If you want Home to send you to the start of the line and not to the top of the document then create a file called DefaultKeyBinding.dict in your ~/Library/KeyBindings folder (might need to create that folder too) with the following contents.

This remapping does the following in most Mac apps including Chrome (some apps do their own key handling):

Home and End will go to start and end of line
ShiftHome and ShiftEnd will select to start and end of line
CtrlHome and CtrlEnd will go to start and end of document
ShiftCtrlHome and ShiftCtrlEnd will select to start and end of document

Note that you will need to reboot / kill Finder after creating this file for it to take effect.

{
"\UF729" = moveToBeginningOfLine:; // home
"\UF72B" = moveToEndOfLine:; // end
"$\UF729" = moveToBeginningOfLineAndModifySelection:; // shift-home
"$\UF72B" = moveToEndOfLineAndModifySelection:; // shift-end
"^\UF729" = moveToBeginningOfDocument:; // ctrl-home
"^\UF72B" = moveToEndOfDocument:; // ctrl-end
"^$\UF729" = moveToBeginningOfDocumentAndModifySelection:; // ctrl-shift-home
"^$\UF72B" = moveToEndOfDocumentAndModifySelection:; // ctrl-shift-end
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment