Skip to content

Instantly share code, notes, and snippets.

Created July 22, 2020 06:20
Show Gist options
  • Save enihsyou/1e0be087d316dd74779f9f0b9020bf12 to your computer and use it in GitHub Desktop.
Save enihsyou/1e0be087d316dd74779f9f0b9020bf12 to your computer and use it in GitHub Desktop.
My DefaultKeyBinding.dict for macOS
/* ~/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 behavior on Windows systems. This makes the Command key
behave like Windows Control key. 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
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
delete: \U007F
For a good reference see
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.
Special thanks to:
Apple document and Internet.
// delete to beginning of paragraph
"^u" = (deleteToBeginningOfParagraph:);
// delete word before cursor
"^w" = (deleteWordBackward:);
// delete word after cursor
"~d" = (deleteWordForward:);
// select word
"~w" = (selectWord:);
// select entire line/paragraph
"~s" = (selectParagraph:);
// copy paragraph
"~y" = (setMark:, moveToBeginningOfParagraph:, moveToEndOfParagraphAndModifySelection:, copy:, swapWithMark:);
// select to beginning of paragraph
"^A" = (moveToBeginningOfParagraphAndModifySelection:);
// select to end of paragraph
"^E" = (moveToEndOfParagraphAndModifySelection:);
// blank line after current
"~o" = (moveToEndOfParagraph:, insertNewline:);
// blank line before current
"~O" = (moveToBeginningOfParagraph:, moveLeft:, insertNewline:);
// Move line up
// "^@\UF700" = (selectParagraph:, setMark:, deleteToMark:, moveLeft:, moveToBeginningOfParagraph:, yank:, moveLeft:, selectToMark:, moveLeft:);
// Move line down
// "^@\UF701" = (selectParagraph:, setMark:, deleteToMark:, moveToEndOfParagraph:, moveRight:, setMark:, yank:, moveLeft:, selectToMark:);
// TextMate Command-Return (Command Return)
"@\U000D" = (moveToEndOfParagraph:, insertNewline:);
// Insert blank line above paragraph (Command Shift Return)
"@$\U000D" = (moveToBeginningOfParagraph:, moveLeft:, insertNewline:);
// bookmark
"~1" = (setMark:);
// jump to bookmark
"~2" = (swapWithMark:,centerSelectionInVisibleArea:);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment