搜了半天终于找到,找这个的原因是我打算试试看 Sublime Text, 而在这之前我一直用的是 Vim. 在尝试使用 Sublime Text 的时候总觉的不能快速的 page up 和 page down 十分的不爽。
OSX 拥有一部分 Emacs Binding: c-f, c-h, c-n ,c-b, 但是以 meta 键开头的 binding 不知道为啥变成了 œ∑†¥øπåƒ√ 这些奇怪字符。结果就变成了可以用 c-v 下翻一页,但是却不能用 m-f 上翻一页,让我十分纠结。今天下决心找了一下如何在 OSX 下搞定完整的 Binding, 终于找到了 superUser 上的这个答案。
原理上原帖看吧,这里把代码复制一下:
mkdir ~/Library/KeyBindings
cat > ~/Library/KeyBindings/DefaultKeyBinding.dict <<EOF
{
/* Keybindings for emacs emulation. Compiled by Jacob Rus.
*
* This is a pretty good set, especially considering that many emacs bindings
* such as C-o, C-a, C-e, C-k, C-y, C-v, C-f, C-b, C-p, C-n, C-t, and
* perhaps a few more, are already built into the system.
*
* BEWARE:
* This file uses the Option key as a meta key. This has the side-effect
* of overriding Mac OS keybindings for the option key, which generally
* make common symbols and non-english letters.
*/
/* Ctrl shortcuts */
"^l" = "centerSelectionInVisibleArea:"; /* C-l Recenter */
"^/" = "undo:"; /* C-/ Undo */
"^_" = "undo:"; /* C-_ Undo */
"^ " = "setMark:"; /* C-Spc Set mark */
"^\@" = "setMark:"; /* C-@ Set mark */
"^w" = "deleteToMark:"; /* C-w Delete to mark */
/* Incremental search. */
/* Uncomment these lines If Incremental Search IM is installed */
/* "^s" = "ISIM_incrementalSearch:"; /* C-s Incremental search */
/* "^r" = "ISIM_reverseIncrementalSearch:"; /* C-r Reverse incremental search */
/* "^g" = "abort:"; /* C-g Abort */
/* Meta shortcuts */
"~f" = "moveWordForward:"; /* M-f Move forward word */
"~b" = "moveWordBackward:"; /* M-b Move backward word */
"~<" = "moveToBeginningOfDocument:"; /* M-< Move to beginning of document */
"~>" = "moveToEndOfDocument:"; /* M-> Move to end of document */
"~v" = "pageUp:"; /* M-v Page Up */
"~/" = "complete:"; /* M-/ Complete */
"~c" = ( "capitalizeWord:", /* M-c Capitalize */
"moveForward:",
"moveForward:");
"~u" = ( "uppercaseWord:", /* M-u Uppercase */
"moveForward:",
"moveForward:");
"~l" = ( "lowercaseWord:", /* M-l Lowercase */
"moveForward:",
"moveForward:");
"~d" = "deleteWordForward:"; /* M-d Delete word forward */
"^~h" = "deleteWordBackward:"; /* M-C-h Delete word backward */
"~\U007F" = "deleteWordBackward:"; /* M-Bksp Delete word backward */
"~t" = "transposeWords:"; /* M-t Transpose words */
"~\@" = ( "setMark:", /* M-@ Mark word */
"moveWordForward:",
"swapWithMark");
"~h" = ( "setMark:", /* M-h Mark paragraph */
"moveToEndOfParagraph:",
"swapWithMark");
/* C-x shortcuts */
"^x" = {
"u" = "undo:"; /* C-x u Undo */
"k" = "performClose:"; /* C-x k Close */
"^f" = "openDocument:"; /* C-x C-f Open (find file) */
"^x" = "swapWithMark:"; /* C-x C-x Swap with mark */
"^m" = "selectToMark:"; /* C-x C-m Select to mark*/
"^s" = "saveDocument:"; /* C-x C-s Save */
"^w" = "saveDocumentAs:"; /* C-x C-w Save as */
};
}
EOF
PS: 修改完配置后要重启应用才能生效,比如你想在 subl 里面生效那就要重启 subl