July 28, 2020

Fixing home/end behaviour on macos

§ tech howto     # macos keyboard

This is just a quick note for how to make Home and End keys behave sensibly, i.e. take you to the beginning or end of a line:

mkdir ~/Library/KeyBindings && touch ~/Library/KeyBindings/DefaultKeyBinding.dict

Then paste into DefaultKeyBinding.dict the following content:

{
  "\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
}

Some also like to remap ctrl- keybindings:

  "^\UF702"  = (moveWordLeft:); // ctrl-left 
  "^$\UF702" = (moveWordLeftAndModifySelection:); // ctrl-shift-left
  "^\UF703"  = (moveWordRight:); // ctrl-right
  "^$\UF703" = (moveWordRightAndModifySelection:); // ctrl-shift-right

You’ll need to restart MacOS for the change to take effect.

Sources:


— `If you knew Time as well as I do,' said the Hatter, `you wouldn't talk about wasting IT. It's HIM.'
$ Last updated: Feb 7, 2021 at 13:38 (EET) $