Skip to content

Instantly share code, notes, and snippets.

@anildigital
Created April 13, 2020 11:55
Show Gist options
  • Save anildigital/a35e4cc7a4b1c88d84a3769f99a95a8f to your computer and use it in GitHub Desktop.
Save anildigital/a35e4cc7a4b1c88d84a3769f99a95a8f to your computer and use it in GitHub Desktop.
{
"\UF729" = moveToBeginningOfParagraph:; // home
"\UF72B" = moveToEndOfParagraph:; // end
"$\UF729" = moveToBeginningOfParagraphAndModifySelection:; // shift-home
"$\UF72B" = moveToEndOfParagraphAndModifySelection:; // shift-end
// Emacs keybindings
"^ " = "setMark:";
"~d" = "deleteWordForward:";
"~w" = "copy:"; /* M-w */
"^w" = "deleteWordBackward:";
"^_" = "undo:";
"^?" = "redo:"; /* C-? */
"~f" = "moveWordForward:";
"~b" = "moveWordBackward:";
"~@" = "selectWord:";
"~v" = "pageUp:";
"^g" = "_cancelKey:"; /* C-g */
"^y" = "paste:"; /* C-y */
"^t" = "transpose:"; /* C-t */
"~t" = "transposeWords:"; /* M-t */
"~<" = "moveToBeginningOfDocument:"; /* M-< */
"~>" = "moveToEndOfDocument:"; /* M-> */
"^V" = "pageDownAndModifySelection:";
"~B" = "moveWordBackwardAndModifySelection:";
"~F" = "moveWordForwardAndModifySelection:";
"~/" = "complete:"; /* M-/ */
}

How to setup DefaultKeyBinding for macOS

  1. Run following command
$ mkdir -p ~/Library/KeyBindings/
  1. Create a file named DefaultKeyBinding.dict at location ~/Library/KeyBindings/DefaultKeyBinding.dict with contents from another file in this gist.

  2. If you use iTerm2 on Mac, do following setting so that you can use option key as meta iterm2Settings

  3. Done. Now restart application and you should get Emacs like keybinding to your macOS applications.

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