Skip to content

Instantly share code, notes, and snippets.

@vladak
Last active April 6, 2025 19:55
Show Gist options
  • Save vladak/e1a4d1a4a52e2416b7119dd222d033d9 to your computer and use it in GitHub Desktop.
Save vladak/e1a4d1a4a52e2416b7119dd222d033d9 to your computer and use it in GitHub Desktop.
home/end macOS key bindings

For the home/end keys to work on external USB keyboard in macOS, it is necessary to set key bindings like so:

mkdir ~/Library/KeyBindings && touch ~/Library/KeyBindings/DefaultKeyBinding.dict
cat << EOF > ~/Library/KeyBindings/DefaultKeyBinding.dict
{
  "\UF729"  = moveToBeginningOfParagraph:; // home
  "\UF72B"  = moveToEndOfParagraph:; // end
  "$\UF729" = moveToBeginningOfParagraphAndModifySelection:; // shift-home
  "$\UF72B" = moveToEndOfParagraphAndModifySelection:; // shift-end
  "^\UF729" = moveToBeginningOfDocument:; // ctrl-home
  "^\UF72B" = moveToEndOfDocument:; // ctrl-end
  "^$\UF729" = moveToBeginningOfDocumentAndModifySelection:; // ctrl-shift-home
  "^$\UF72B" = moveToEndOfDocumentAndModifySelection:; // ctrl-shift-end
}
EOF

Relogin for the changes to take effect.

Links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment