Skip to content

Instantly share code, notes, and snippets.

@hnagato
Last active February 19, 2018 09:28
Show Gist options
  • Save hnagato/635666 to your computer and use it in GitHub Desktop.
Save hnagato/635666 to your computer and use it in GitHub Desktop.
Cocoaのキーバインドをよりemacsに近づける
/* ~/Library/KeyBindings/DefaultKeyBinding.dict */
{
/* Auto-Paring */
// "(" = ( "insertText:", "()", "moveBackward:" );
// "{" = ( "insertText:", "{}", "moveBackward:" );
// "[" = ( "insertText:", "[]", "moveBackward:" );
"~f" = "moveWordForward:"; /* M-f */
"~b" = "moveWordBackward:"; /* M-b */
"~<" = "moveToBeginningOfDocument:"; /* M-< */
"~>" = "moveToEndOfDocument:"; /* M-> */
"~v" = "pageUp:"; /* M-v */
"^v" = "pageDown:"; /* C-v */
"~d" = "deleteWordForward:"; /* M-d */
"~^h" = "deleteWordBackward:"; /* M-C-h */
"~\010" = "deleteWordBackward:"; /* M-backspace */
"~\177" = "deleteWordBackward:"; /* M-delete */
"~\UF728" = "deleteWordForward:"; /* delete */
"\UF729" = "moveToBeginningOfDocument:"; /* home */
"\UF72B" = "moveToEndOfDocument:"; /* end */
"@\UF729" = "moveToBeginningOfParagraph:"; /* A-home */
"@\UF72B" = "moveToEndOfParagraph:"; /* A-end */
"@\UF700" = "moveToBeginningOfDocument:"; /* A-up */
"@\UF701" = "moveToEndOfDocument:"; /* A-down */
"^\UF700" = "pageUp:"; /* C-up */
"^\UF701" = "pageDown:"; /* C-down */
"\UF72C" = "pageUp:"; /* page-up */
"\UF72D" = "pageDown:"; /* page-down */
"^/" = "undo:"; /* C-/ */
"~c" = "capitalizeWord:"; /* M-c */
"~u" = "uppercaseWord:"; /* M-u */
"~l" = "lowercaseWord:"; /* M-l */
"^t" = "transpose:"; /* C-t */
"~t" = "transposeWords:"; /* M-t */
"~/" = "complete:"; /* M-/ */
"^g" = "_cancelKey:"; /* C-g */
"^a" = "moveToBeginningOfLine:"; /* C-a */
"^e" = "moveToEndOfLine:"; /* C-e */
"^l" = "centerSelectionInVisibleArea:"; /* C-l */
"^x" = {
"^x" = "swapWithMark:"; /* C-x C-x */
"^m" = "selectToMark:"; /* C-x C-m */
"^f" = "openDocument:"; /* C-x C-f */
"^s" = "saveDocument:"; /* C-x C-s */
"^w" = "saveAsDocument:"; /* C-x C-w */
"k" = "performClose:"; /* C-x C-k */
"u" = "undo:"; /* C-x u */
// surround
"'" = (
"setMark:",
"deleteToMark:",
"insertText:", "'", "yank:", "insertText:", "'",
);
"\"" = (
"setMark:",
"deleteToMark:",
"insertText:", "\"", "yank:", "insertText:", "\"",
);
"[" = (
"setMark:",
"deleteToMark:",
"insertText:", "[", "yank:", "insertText:", "]",
);
"{" = (
"setMark:",
"deleteToMark:",
"insertText:", "{", "yank:", "insertText:", "}",
);
"(" = (
"setMark:",
"deleteToMark:",
"insertText:", "(", "yank:", "insertText:", ")",
);
"<" = (
"setMark:",
"deleteToMark:",
"insertText:", "<", "yank:", "insertText:", ">",
);
"^[" = (
"setMark:",
"deleteToMark:",
"insertText:", "「", "yank:", "insertText:", "」",
);
};
/*
* マーク設定みたいなの。(Emacsスタイルのmarkとpointのバインディングは
* 実装されてはいるもののデフォルトでは区切られない。テキストシステムでは
* markとpointは範囲であり、位置ではない。"point" は 選択の範囲を示す)
*/
"^ " = "setMark:"; /* C-space */
"^w" = "deleteToMark:"; /* C-w */
"~y" = "yankAndSelect:"; /* Option-y */
/* Mac 流の F1〜F5 のバインディング */
// "\UF704" = "undo:"; /* F1 */
// "\UF705" = "cut:"; /* F2 */
// "\UF706" = "copy:"; /* F3 */
// "\UF707" = "paste:"; /* F4 */
// "\UF708" = "_cancelKey:"; /* F5 */
}
@hnagato
Copy link
Author

hnagato commented Nov 28, 2013

defaults write -g NSRepeatCountBinding -string "^u"
defaults write -g NSTextKillRingSize -string 4
defaults write NSGlobalDomain AppleKeyboardUIMode -int 3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment