Skip to content

Instantly share code, notes, and snippets.

@taiya
Last active July 22, 2018 18:55
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 taiya/b05f543e61bce8029d18ff4f8a419caa to your computer and use it in GitHub Desktop.
Save taiya/b05f543e61bce8029d18ff4f8a419caa to your computer and use it in GitHub Desktop.
Changes shortcuts in OSX to have similar behavior to Linux
/* ~/Library/KeyBindings/DefaultKeyBinding.Dict
Based on: https://gist.github.com/trusktr/1e5e516df4e8032cbc3d
System file: /System/Library/Frameworks/AppKit.framework/Resources/StandardKeyBinding.dict
Official info: https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/EventOverview/TextDefaultsBindings/TextDefaultsBindings.html
Complex example: https://github.com/ttscoff/KeyBindings/blob/master/DefaultKeyBinding.dict
NOTE:
To use Control instead of Command, either swap Control and
Command in Apple->System Preferences->Keyboard->Modifier Keys...
or replace @ with ^ in this file.
Here is a rough cheatsheet for syntax.
Key Modifiers
^ : Ctrl
$ : Shift
~ : Option (Alt)
@ : Command (Apple)
# : Numeric Keypad
Non-Printable Key Codes
Standard
Up Arrow: \UF700 Backspace: \U0008 F1: \UF704
Down Arrow: \UF701 Tab: \U0009 F2: \UF705
Left Arrow: \UF702 Escape: \U001B F3: \UF706
Right Arrow: \UF703 Enter: \U000A ...
Insert: \UF727 Page Up: \UF72C
Delete: \UF728 Page Down: \UF72D
Home: \UF729 Print Screen: \UF72E
End: \UF72B Scroll Lock: \UF72F
Break: \UF732 Pause: \UF730
SysReq: \UF731 Menu: \UF735
Help: \UF746
OS X
delete: \U007F
To unbind, simply assign to empty string ""
For a good reference see http://osxnotes.net/keybindings.html.
*/
{
"~\UF702" = "moveWordBackward:"; /* Option + LeftArrow */
"~\UF703" = "moveWordForward:"; /* Option + RightArrow */
"~$\UF702" = "moveWordBackwardAndModifySelection:"; /* Option + Shift + LeftArrow */
"~$\UF703" = "moveWordForwardAndModifySelection:"; /* Option + Shift + RightArrow */
"^\UF702" = "moveWordBackward:"; /* Cmd + LeftArrow */
"^\UF703" = "moveWordForward:"; /* Cmd + RightArrow */
"^$\UF702" = "moveWordBackwardAndModifySelection:"; /* Cmd + Shift + RightArrow */
"^$\UF703" = "moveWordForwardAndModifySelection:"; /* Cmd + Shift + RightArrow */
"^\U007F" = "deleteWordBackward:"; /* Cmd + Backspace */
"^\UF728" = "deleteWordForward:"; /* Cmd + Delete */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment