Skip to content

Instantly share code, notes, and snippets.

@ma-al
Last active August 17, 2020 03:10
Show Gist options
  • Save ma-al/0ce198affec24eac8575de7743a35913 to your computer and use it in GitHub Desktop.
Save ma-al/0ce198affec24eac8575de7743a35913 to your computer and use it in GitHub Desktop.
// Bits and pieces gathered from:
// - https://damieng.com/blog/2015/04/24/make-home-end-keys-behave-like-windows-on-mac-os-x
// - comments from other users on that post
//
// Put this file inside ~/Library/KeyBindings
// - you may have to create the folder
// - may also need to change the owner to you `chown`
// - may also need to allow access `chmod 777 ~/Library/KeyBindings`
//
// Also may need to allow access to this file itself
// - `chmod 777 ~/Library/KeyBindings/DefaultKeyBinding.dict`
{
"\UF729" = moveToBeginningOfLine:; //home
"\UF72B" = moveToEndOfLine:; //end
"$\UF729" = moveToBeginningOfLineAndModifySelection:; //shift-home
"$\UF72B" = moveToEndOfLineAndModifySelection:; //shift-end
}
// Other possible combos:
// - "^$\UF729" = moveToBeginningOfDocumentAndModifySelection:; //ctl-end
// - "^\UF72B" = moveToEndOfDocument:; //ctl-end
// - "@\UF72B" = moveToEndOfDocument:; //cmd-end

Explanation

On macOS, this changes the Home and End keys on a keyboard to go to the beginning and end of the current line. This is when editing text in all applications (e.g., in any text editor and in a text edit box within Safari).

Working on macOS Catalina 10.15.6 (19G73). So far, it's working in:

  • SourceTree
  • Sublime
  • Visual Studio Code
  • Safari
  • MS Teams

Source

Bits and pieces were gathered from:

How

Put DefaultKeyBinding.dict inside ~/Library/KeyBindings

  • you may have to create the folder
  • may also need to change the owner to you chown <your-username> ~/Library/KeyBindings
  • may also need to allow access chmod 777 ~/Library/KeyBindings

Also may need to allow permissions to the file itself

  • chmod 777 ~/Library/KeyBindings/DefaultKeyBinding.dict

Other Possible Combos

{
  "^$\UF729" = moveToBeginningOfDocumentAndModifySelection:; //ctl-end
  "^\UF72B" = moveToEndOfDocument:; //ctl-end
  "@\UF72B" = moveToEndOfDocument:; //cmd-end
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment