Skip to content

Instantly share code, notes, and snippets.

@dsvyrjm
Forked from lenalebt/DefaultKeyBinding.dict
Last active November 8, 2020 00:20
Show Gist options
  • Save dsvyrjm/7fa54b819fe6ece60c5fe078bb2fc159 to your computer and use it in GitHub Desktop.
Save dsvyrjm/7fa54b819fe6ece60c5fe078bb2fc159 to your computer and use it in GitHub Desktop.
How to use a typical Linux / Windows Keybinding on MacOS (tested with 10.15.6 Catalina)
/*
PUT THIS FILE IN ~/Library/KeyBindings/DefaultKeyBinding.dict
HOW TO CREATE THIS FILE
sudo mkdir ~/Library/KeyBindings/
sudo touch ~/Library/KeyBindings/DefaultKeyBinding.dict
sudo cmod 644 ~/Library/KeyBindings/DefaultKeyBinding.dict
sudo chown itSme ~/Library/KeyBindings/DefaultKeyBinding.dict # assumes your username="itSme"
AND THAN EDIT FILE
open -e ~/Library/KeyBindings/DefaultKeyBinding.dict
This file remaps the key bindings of a single user on Mac OS X 10.5 to more closely
match default behaviour on Windows systems. This particular mapping assumes
that you have also switched the Control and Command keys already.
This key mapping is more appropriate after switching Ctrl for Command in this menu:
Apple->System Preferences->Keyboard & Mouse->Keyboard->Modifier Keys...->
Change Control Key to Command
Change Command key to Control
This applies to OS X 10.5 and possibly other versions.
Here is a rough cheatsheet for syntax.
Key Modifiers
^ : Ctrl
$ : Shift
~ : Option (Alt)
@ : Command (Apple)
# : Numeric Keypad
Non-Printable Key Codes
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
NOTE: typically the Windows 'Insert' key is mapped to what Macs call 'Help'.
Regular Mac keyboards don't even have the Insert key, but provide 'Fn' instead,
which is completely different.
*/
/* Swap Cmd with Option */
{
"~\UF702" = "moveToBeginningOfLine:"; /* Option + LeftArrow */
"~\UF703" = "moveToEndOfLine:"; /* Option + RightArrow */
"~$\UF703" = "moveToEndOfLineAndModifySelection:"; /* Option + Shift + LeftArrow */
"~$\UF702" = "moveToBeginningOfLineAndModifySelection:"; /* Option + Shift + RightArrow */
"@\UF702" = "moveWordBackward:"; /* Cmd + LeftArrow */
"@\UF703" = "moveWordForward:"; /* Cmd + RightArrow */
"@$\UF702" = "moveWordBackwardAndModifySelection:"; /* Shift + Cmd + LeftArrow */
"@$\UF703" = "moveWordForwardAndModifySelection:"; /* Shift + Cmd + RightArrow */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment