Skip to content

Instantly share code, notes, and snippets.

@mawaldne
Created October 2, 2013 03:03
Show Gist options
  • Save mawaldne/6788563 to your computer and use it in GitHub Desktop.
Save mawaldne/6788563 to your computer and use it in GitHub Desktop.
/* ~/Library/KeyBindings/DefaultKeyBinding.dict */
{
/*
* Keybindings for emacs emulation.
*
* WARNING! After Mountain Lion, this file cannot be symbolic linked to another file,
* you need to put this file in ~/Library/KeyBindings/DefaultKeyBinding.dict directly
*
* Reference:
* http://www.hcs.harvard.edu/~jrus/site/cocoa-text.html
* http://www.hcs.harvard.edu/~jrus/Site/KeyBindings/Emacs%20Opt%20Bindings.dict
* http://www.deepsky.com/~misaka/MacOSX/DefaultKeyBinding.dict
* http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/EventOverview/TextDefaultsBindings/TextDefaultsBindings.html#//apple_ref/doc/uid/20000468-SW1
*
* System default setting is located at (open with Xcode)
* /System/Library/Frameworks/AppKit.framework/Resources/StandardKeyBinding.dict
*
* Remarks:
* - ^/ undo is not implmented due to conflictions with Xcode
*
* - "^y" maps to "yank:" and "^w" maps "deleteToMark:", but the kill-ring is independent with Mac
* clipboard may cause confusions.
*/
/* Remap Home / End to be correct */
/* http://soodev.wordpress.com/2011/07/04/mac-os-x-remapping-home-and-end-keys/ */
"\UF729" = "moveToBeginningOfLine:"; /* Home */
"\UF72B" = "moveToEndOfLine:"; /* End */
"$\UF729" = "moveToBeginningOfLineAndModifySelection:"; /* Shift + Home */
"$\UF72B" = "moveToEndOfLineAndModifySelection:"; /* Shift + End */
"^\UF729" = "moveToBeginningOfDocument:"; /* Ctrl + Home */
"^\UF72B" = "moveToEndOfDocument:"; /* Ctrl + End */
"$^\UF729" = "moveToBeginningOfDocumentAndModifySelection:"; /* Shift + Ctrl + Home */
"$^\UF72B" = "moveToEndOfDocumentAndModifySelection:"; /* Shift + Ctrl + End */
/* Emacs Ctrl Key Bindings (^a/e/n/p/b/f/d/k/t are already defined in Mac OS ) */
"^l" = "centerSelectionInVisibleArea:";
"^_" = "undo:";
"^w" = "deleteToMark:";
"^y" = "yank:"; /* Or map to paste: */
"^j" = "insertNewline:";
/* Emacs Meta Key Bindings */
"~f" = "moveWordForward:";
"~b" = "moveWordBackward:";
"~<" = "moveToBeginningOfDocument:";
"~>" = "moveToEndOfDocument:";
"~w" = "copy:";
"~$2" = "selectWord:"; /* TODO: M-@: it doesn't work. By default, it inputs Euro symbol */
"~d" = "deleteWordForward:";
"~\U007F"= "deleteWordBackward:"; /* M-DEL */
/* Emacs PageUp/Down */
"^v" = "pageDown:";
"~v" = "pageUp:";
/* The following key bindings cannot be mapped in Windows with KeyRemap4MacBook */
"~c" = "capitalizeWord:";
"~l" = "lowercaseWord:";
"~/" = "complete:"; /* M-/ Complete (Same as ESC) */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment