Last active
July 17, 2024 17:40
-
-
Save zsimic/1367779 to your computer and use it in GitHub Desktop.
OSX key bindings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
/* ~/Library/KeyBindings/DefaultKeyBinding.dict | |
See https://gist.github.com/zsimic/1367779, prefix cheatsheet: | |
Char Short Key | |
$ S- Shift ⇧ | |
^ C- CTRL ⌃ | |
~ O- Option ⌥ (⊞ Win key position on PC) | |
@ M- Command ⌘ (Alt position on PC) | |
# Numeric Keypad | |
*/ | |
/*---- Navigation ----*/ | |
/* Up/down is mostly for a nicer laptop navigation (no Home, PgUp etc keys) */ | |
"~\Uf700" = "pageUp:"; /* O-up Page up */ | |
"~$\Uf700" = "pageUpAndModifySelection:"; /* O-S-up Select + page up */ | |
"@\Uf700" = "moveToBeginningOfDocument:"; /* M-up Beginning of document */ | |
"@$\Uf700" = "moveToBeginningOfDocumentAndModifySelection:"; /* M-S-up Select to beginning of document */ | |
"~\Uf701" = "pageDown:"; /* O-down Page down */ | |
"~$\Uf701" = "pageDownpAndModifySelection:"; /* O-S-down Select + page down */ | |
"@\Uf701" = "moveToEndOfDocument:"; /* M-down End of document */ | |
"@$\Uf701" = "moveToEndOfDocumentAndModifySelection:"; /* M-S-down Select to end of document */ | |
/* Windows defaults are more convenient */ | |
"^\Uf702" = "moveWordBackward:"; /* C-left Move word left */ | |
"^$\Uf702" = "moveWordBackwardAndModifySelection:"; /* C-S-left Select word left */ | |
"^\Uf703" = "moveWordForward:"; /* C-right Move word right */ | |
"^$\Uf703" = "moveWordForwardAndModifySelection:"; /* C-S-right Select word right */ | |
"\Uf729" = "moveToBeginningOfLine:"; /* home Beginning of line */ | |
"$\Uf729" = "moveToBeginningOfLineAndModifySelection:"; /* S-home Select to beginning of line */ | |
"^\Uf729" = "moveToBeginningOfDocument:"; /* C-home Beginning of document */ | |
"^$\Uf729" = "moveToBeginningOfDocumentAndModifySelection:"; /* C-S-home Select to beginning of document */ | |
"\Uf72b" = "moveToEndOfLine:"; /* end End of line */ | |
"$\Uf72b" = "moveToEndOfLineAndModifySelection:"; /* S-end Select to end of line */ | |
"^\Uf72b" = "moveToEndOfDocument:"; /* C-end End of document */ | |
"^$\Uf72b" = "moveToEndOfDocumentAndModifySelection:"; /* C-S-end Select to end of document */ | |
"\Uf72c" = "pageUp:"; /* PageUp Page up */ | |
"$\Uf72c" = "pageUpAndModifySelection:"; /* S-PageUp Select + page up */ | |
"@\Uf72c" = "scrollPageUp:"; /* M-PageUp Scroll page up */ | |
"\Uf72d" = "pageDown:"; /* PageDn Page down */ | |
"$\Uf72d" = "pageDownAndModifySelection:"; /* S-PageDn Select + page down */ | |
"@\Uf72d" = "scrollPageDown:"; /* M-PageDn Scroll page down */ | |
/*---- Editing ----*/ | |
"^\U007f" = "deleteWordBackward:"; /* C-Del Delete word backward */ | |
"^\Uf728" = "deleteWordForward:"; /* C-FwdDel Delete word forward */ | |
"$\U000a" = "insertLineBreak:"; /* S-Ret Line break */ | |
} |
You've assembled an amazing resource... Thank you!
This is really helpful. Thank you!
Great resource! Thank you!
Just a note if anyone's faced the same issue. For the following to work I had to disable or change the Mission Control shortcuts for moving spaces left and right.
/* Windows defaults are more convenient */
"^\Uf702" = "moveWordBackward:"; /* C-left Move word left */
"^$\Uf702" = "moveWordBackwardAndModifySelection:"; /* C-S-left Select word left */
"^\Uf703" = "moveWordForward:"; /* C-right Move word right */
"^$\Uf703" = "moveWordForwardAndModifySelection:"; /* C-S-right Select word right */
Thank you for this, truly helpful. Question, is there a shortcut string that would specifically point to the right option
key? Can left and right be differentiated in the key bindings?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example DefaultKeyBinding.dict
Notes
Key combinations that enter dead key states cannot be reassigned.
They include
option-E
,option-I
,option-N
,option-U
, andoption-`
in the U.S. keyboard layout.setMark:, selectToMark:
removes anchoring so that the methods that modify a selection expand the selection.delete:
(bound to the clear key) doesn't delete anything if there is no selection.deleteBackward:
(bound to the delete key) doesn't add deleted selections to the kill ring.deleteBackward:
doesn't add single character selections to the kill ring butsetMark:
,deleteToMark:
does.scrollPageDown:
(bound to page down) doesn't move the caret butpageDown:
(bound to option-page down) does.I haven't changed the page down key to
pageDown:
becausepageDown:
doesn't do anything in Safari or other web views.moveToBeginningOfParagraphAndModifySelection:, moveToEndOfParagraphAndModifySelection:
orselectParagraph:, moveForwardAndModifySelection:, moveBackwardAndModifySelection:, moveBackwardAndModifySelection:, moveToEndOfParagraphAndModifySelection:
select a line without a newline.
delete:, setMark:, paste:, selectToMark:
pastes text and selects the pasted text.If you remove the
delete:
method, the original selection is kept when the original selection is longer than the pasted text.defaults write -g NSTextKillRingSize -int 100
makesyankPop:
cycle through previously killed pieces of text.Methods
Emacs keybindings
This page includes a few more keybindings, but for example
transposeWords:
doesn't work in most applications,openDocument:
andsaveDocument:
don't work in applications that use auto-save, andperformClose:
doesn't work everywhere either.More links
http://www.hcs.harvard.edu/~jrus/site/cocoa-text.html
Apple TextDefaultsBindings
https://github.com/ttscoff/KeyBindings/blob/master/DefaultKeyBinding.dict
Salvaged from
gnustep/apps/gorm/tags/Gorm-0_1_0/ClassInformation.plist
: