Skip to content

Instantly share code, notes, and snippets.

@HackingGate
Last active June 1, 2025 02:46
Show Gist options
  • Save HackingGate/89a86eac469a8e51dbe74548240dcb5e to your computer and use it in GitHub Desktop.
Save HackingGate/89a86eac469a8e51dbe74548240dcb5e to your computer and use it in GitHub Desktop.
Emacs-style keymap for VSCode with memory hints (mnemonics)
[
/* 0. UNBIND VS Code defaults that clash (→ new Emacs-style key) */
{ "key": "ctrl+f", "command": "-actions.find" }, // C-s/C-r = isearch-forward/backward
{ "key": "ctrl+s", "command": "-workbench.action.files.save" }, // C-x C-s = save-buffer
{ "key": "ctrl+v", "command": "-editor.action.clipboardPasteAction" }, // C-y = yank (paste)
{ "key": "ctrl+y", "command": "-redo" }, // C-/ = undo, C-? = redo
{ "key": "ctrl+p", "command": "-workbench.action.quickOpen" }, // C-x C-f = find-file
{ "key": "ctrl+n", "command": "-workbench.action.files.newUntitledFile" }, // C-x C-n = new-file
{ "key": "ctrl+a", "command": "-editor.action.selectAll" }, // C-x h = mark-whole-buffer
{ "key": "ctrl+e", "command": "-workbench.action.files.saveAs" }, // C-x C-w = write-file
{ "key": "ctrl+w", "command": "-workbench.action.closeActiveEditor" }, // C-x k = kill-buffer
{ "key": "ctrl+/", "command": "-editor.action.commentLine" }, // M-; = comment-dwim
{ "key": "ctrl+g", "command": "-workbench.action.gotoLine" }, // M-g g = goto-line
{ "key": "ctrl+x", "command": "-editor.action.clipboardCutAction" }, // C-w = kill-region (cut)
/* macOS Command key unbindings */
{ "key": "cmd+f", "command": "-actions.find" }, // Unbind macOS find
{ "key": "cmd+s", "command": "-workbench.action.files.save" }, // Unbind macOS save
{ "key": "cmd+v", "command": "-editor.action.clipboardPasteAction" }, // Unbind macOS paste
{ "key": "cmd+y", "command": "-redo" }, // Unbind macOS redo
{ "key": "cmd+p", "command": "-workbench.action.quickOpen" }, // Unbind macOS quick open
{ "key": "cmd+n", "command": "-workbench.action.files.newUntitledFile" }, // Unbind macOS new file
{ "key": "cmd+a", "command": "-editor.action.selectAll" }, // Unbind macOS select all
{ "key": "cmd+e", "command": "-workbench.action.files.saveAs" }, // Unbind macOS save as
{ "key": "cmd+w", "command": "-workbench.action.closeActiveEditor" }, // Unbind macOS close editor
{ "key": "cmd+/", "command": "-editor.action.commentLine" }, // Unbind macOS comment line
{ "key": "cmd+g", "command": "-workbench.action.gotoLine" }, // Unbind macOS go to line
{ "key": "cmd+x", "command": "-editor.action.clipboardCutAction" }, // Unbind macOS cut
/* 1. Basic cursor movement */
{ "key": "ctrl+f", "command": "cursorRight", "when": "textInputFocus || terminalFocus || searchViewletFocus || inSearchEditor" }, // C-f = forward-char
{ "key": "ctrl+b", "command": "cursorLeft", "when": "textInputFocus || terminalFocus || searchViewletFocus || inSearchEditor" }, // C-b = backward-char
{ "key": "ctrl+n", "command": "cursorDown", "when": "textInputFocus || terminalFocus || searchViewletFocus || inSearchEditor" }, // C-n = next-line
{ "key": "ctrl+p", "command": "cursorUp", "when": "textInputFocus || terminalFocus || searchViewletFocus || inSearchEditor" }, // C-p = previous-line
{ "key": "ctrl+a", "command": "cursorHome", "when": "textInputFocus || terminalFocus || searchViewletFocus || inSearchEditor" }, // C-a = beginning-of-line
{ "key": "ctrl+e", "command": "cursorEnd", "when": "textInputFocus || terminalFocus || searchViewletFocus || inSearchEditor" }, // C-e = end-of-line
{ "key": "alt+f", "command": "cursorWordEndRight", "when": "textInputFocus || terminalFocus || searchViewletFocus || inSearchEditor" }, // M-f = forward-word
{ "key": "alt+b", "command": "cursorWordStartLeft", "when": "textInputFocus || terminalFocus || searchViewletFocus || inSearchEditor" }, // M-b = backward-word
{ "key": "ctrl+v", "command": "scrollPageDown", "when": "textInputFocus || terminalFocus || searchViewletFocus || inSearchEditor" }, // C-v = scroll-down
{ "key": "alt+v", "command": "scrollPageUp", "when": "textInputFocus || terminalFocus || searchViewletFocus || inSearchEditor" }, // M-v = scroll-up
/* 2. Kill / delete / yank */
{ "key": "ctrl+k", "command": "deleteAllRight", "when": "textInputFocus || terminalFocus" }, // C-k = kill-line
{ "key": "ctrl+d", "command": "deleteRight", "when": "textInputFocus || terminalFocus" }, // C-d = delete-char
{ "key": "alt+d", "command": "deleteWordEndRight", "when": "textInputFocus || terminalFocus" }, // M-d = kill-word
{ "key": "alt+backspace", "command": "deleteWordStartLeft", "when": "textInputFocus || terminalFocus" }, // M-DEL = backward-kill-word
{ "key": "ctrl+w", "command": "editor.action.clipboardCutAction", "when": "textInputFocus || terminalFocus" }, // C-w = kill-region (cut)
{ "key": "alt+w", "command": "editor.action.clipboardCopyAction", "when": "textInputFocus || terminalFocus" }, // M-w = kill-ring-save (copy)
{ "key": "ctrl+y", "command": "editor.action.clipboardPasteAction", "when": "textInputFocus || terminalFocus" }, // C-y = yank (paste)
{ "key": "alt+y", "command": "emacs.yankPop", "when": "textInputFocus || terminalFocus" }, // M-y = yank-pop (cycle paste)
/* 3. Incremental search */
{ "key": "ctrl+s", "command": "actions.find", "when": "(editorFocus || terminalFocus) && !findWidgetVisible" }, // C-s = isearch-forward
{ "key": "ctrl+s", "command": "editor.action.nextMatchFindAction", "when": "(editorFocus || terminalFocus) && findWidgetVisible" }, // C-s = isearch-repeat-forward
{ "key": "ctrl+r", "command": "actions.find", "when": "(editorFocus || terminalFocus) && !findWidgetVisible" }, // C-r = isearch-backward
{ "key": "ctrl+r", "command": "editor.action.previousMatchFindAction", "when": "(editorFocus || terminalFocus) && findWidgetVisible" }, // C-r = isearch-repeat-backward
/* 4. Mark & region */
{ "key": "ctrl+space", "command": "editor.action.setSelectionAnchor", "when": "textInputFocus || terminalFocus" }, // C-SPC = set-mark-command
{ "key": "ctrl+x ctrl+x", "command": "editor.action.gotoSelectionAnchor", "when": "textInputFocus || terminalFocus" }, // C-x C-x = exchange-point-and-mark
/* 5. File / buffer (C-x prefix) */
{ "key": "ctrl+x ctrl+s", "command": "workbench.action.files.save", "when": "textInputFocus || terminalFocus" }, // C-x C-s = save-buffer
{ "key": "ctrl+x ctrl+w", "command": "workbench.action.files.saveAs", "when": "textInputFocus || terminalFocus" }, // C-x C-w = write-file
{ "key": "ctrl+x ctrl+f", "command": "workbench.action.files.openFile", "when": "textInputFocus || terminalFocus" }, // C-x C-f = find-file
{ "key": "ctrl+x ctrl+o", "command": "workbench.action.quickOpen", "when": "textInputFocus || terminalFocus" }, // C-x C-o = quick-find-file
{ "key": "ctrl+x k", "command": "workbench.action.closeActiveEditor", "when": "textInputFocus || terminalFocus" }, // C-x k = kill-buffer
{ "key": "ctrl+x b", "command": "workbench.action.showAllEditors", "when": "textInputFocus || terminalFocus" }, // C-x b = switch-to-buffer
{ "key": "ctrl+x h", "command": "editor.action.selectAll", "when": "textInputFocus || terminalFocus" }, // C-x h = mark-whole-buffer
{ "key": "ctrl+x ctrl+n", "command": "workbench.action.files.newUntitledFile", "when": "textInputFocus || terminalFocus" }, // C-x C-n = new-empty-buffer
/* 6. Undo, comment, abort */
{ "key": "ctrl+/", "command": "undo", "when": "textInputFocus || terminalFocus" }, // C-/ = undo
{ "key": "ctrl+x u", "command": "undo", "when": "textInputFocus || terminalFocus" }, // C-x u = undo
{ "key": "ctrl+shift+/", "command": "redo", "when": "textInputFocus || terminalFocus" }, // C-? = redo
{ "key": "ctrl+shift+-", "command": "redo", "when": "textInputFocus || terminalFocus" }, // C-_ = redo
{ "key": "alt+;", "command": "editor.action.commentLine", "when": "textInputFocus || terminalFocus" }, // M-; = comment-dwim
{ "key": "alt+g g", "command": "workbench.action.gotoLine", "when": "textInputFocus || terminalFocus" }, // M-g g = goto-line
{ "key": "ctrl+g", "command": "cancelSelection", "when": "textInputFocus || terminalFocus" }, // C-g = keyboard-quit
{ "key": "ctrl+g", "command": "workbench.action.closeQuickOpen", "when": "inQuickOpen || terminalFocus" }, // C-g = close quick open
/* 7. Terminal passthrough */
{ "key": "ctrl+f", "command": "workbench.action.terminal.sendSequence", "args": { "text": "\u0006" }, "when": "terminalFocus && terminalProcessSupported" }, // C-f = forward-char
{ "key": "ctrl+b", "command": "workbench.action.terminal.sendSequence", "args": { "text": "\u0002" }, "when": "terminalFocus && terminalProcessSupported" }, // C-b = backward-char
{ "key": "ctrl+n", "command": "workbench.action.terminal.sendSequence", "args": { "text": "\u000e" }, "when": "terminalFocus && terminalProcessSupported" }, // C-n = next-line
{ "key": "ctrl+p", "command": "workbench.action.terminal.sendSequence", "args": { "text": "\u0010" }, "when": "terminalFocus && terminalProcessSupported" }, // C-p = previous-line
{ "key": "ctrl+a", "command": "workbench.action.terminal.sendSequence", "args": { "text": "\u0001" }, "when": "terminalFocus && terminalProcessSupported" }, // C-a = beginning-of-line
{ "key": "ctrl+e", "command": "workbench.action.terminal.sendSequence", "args": { "text": "\u0005" }, "when": "terminalFocus && terminalProcessSupported" }, // C-e = end-of-line
{ "key": "alt+f", "command": "workbench.action.terminal.sendSequence", "args": { "text": "\u001bf" }, "when": "terminalFocus && terminalProcessSupported" }, // M-f = forward-word
{ "key": "alt+b", "command": "workbench.action.terminal.sendSequence", "args": { "text": "\u001bb" }, "when": "terminalFocus && terminalProcessSupported" }, // M-b = backward-word
{ "key": "ctrl+v", "command": "workbench.action.terminal.sendSequence", "args": { "text": "\u0016" }, "when": "terminalFocus && terminalProcessSupported" }, // C-v = scroll-down
{ "key": "alt+v", "command": "workbench.action.terminal.sendSequence", "args": { "text": "\u001bv" }, "when": "terminalFocus && terminalProcessSupported" }, // M-v = scroll-up
{ "key": "ctrl+k", "command": "workbench.action.terminal.sendSequence", "args": { "text": "\u000b" }, "when": "terminalFocus && terminalProcessSupported" }, // C-k = kill-line
{ "key": "ctrl+d", "command": "workbench.action.terminal.sendSequence", "args": { "text": "\u0004" }, "when": "terminalFocus && terminalProcessSupported" }, // C-d = delete-char
{ "key": "alt+d", "command": "workbench.action.terminal.sendSequence", "args": { "text": "\u001bd" }, "when": "terminalFocus && terminalProcessSupported" }, // M-d = kill-word
{ "key": "alt+backspace", "command": "workbench.action.terminal.sendSequence", "args": { "text": "\u001b\u007f" }, "when": "terminalFocus && terminalProcessSupported" }, // M-DEL = backward-kill-word
{ "key": "ctrl+w", "command": "workbench.action.terminal.sendSequence", "args": { "text": "\u0017" }, "when": "terminalFocus && terminalProcessSupported" }, // C-w = kill-region
{ "key": "alt+w", "command": "workbench.action.terminal.sendSequence", "args": { "text": "\u001bw" }, "when": "terminalFocus && terminalProcessSupported" }, // M-w = kill-ring-save
{ "key": "ctrl+y", "command": "workbench.action.terminal.sendSequence", "args": { "text": "\u0019" }, "when": "terminalFocus && terminalProcessSupported" }, // C-y = yank
{ "key": "alt+y", "command": "workbench.action.terminal.sendSequence", "args": { "text": "\u001by" }, "when": "terminalFocus && terminalProcessSupported" }, // M-y = yank-pop
{ "key": "ctrl+s", "command": "workbench.action.terminal.sendSequence", "args": { "text": "\u0013" }, "when": "terminalFocus && terminalProcessSupported" }, // C-s = isearch-forward
{ "key": "ctrl+r", "command": "workbench.action.terminal.sendSequence", "args": { "text": "\u0012" }, "when": "terminalFocus && terminalProcessSupported" }, // C-r = isearch-backward
{ "key": "ctrl+space", "command": "workbench.action.terminal.sendSequence", "args": { "text": "\u0000" }, "when": "terminalFocus && terminalProcessSupported" }, // C-SPC = set-mark-command
{ "key": "ctrl+x ctrl+x", "command": "workbench.action.terminal.sendSequence", "args": { "text": "\u0018\u0018" }, "when": "terminalFocus && terminalProcessSupported" }, // C-x C-x = exchange-point-and-mark
{ "key": "ctrl+x ctrl+s", "command": "workbench.action.terminal.sendSequence", "args": { "text": "\u0018\u0013" }, "when": "terminalFocus && terminalProcessSupported" }, // C-x C-s = save-buffer
{ "key": "ctrl+x ctrl+w", "command": "workbench.action.terminal.sendSequence", "args": { "text": "\u0018\u0017" }, "when": "terminalFocus && terminalProcessSupported" }, // C-x C-w = write-file
{ "key": "ctrl+x ctrl+f", "command": "workbench.action.terminal.sendSequence", "args": { "text": "\u0018\u0006" }, "when": "terminalFocus && terminalProcessSupported" }, // C-x C-f = find-file
{ "key": "ctrl+x ctrl+o", "command": "workbench.action.terminal.sendSequence", "args": { "text": "\u0018\u000f" }, "when": "terminalFocus && terminalProcessSupported" }, // C-x C-o = delete-blank-lines
{ "key": "ctrl+x k", "command": "workbench.action.terminal.sendSequence", "args": { "text": "\u0018k" }, "when": "terminalFocus && terminalProcessSupported" }, // C-x k = kill-buffer
{ "key": "ctrl+x b", "command": "workbench.action.terminal.sendSequence", "args": { "text": "\u0018b" }, "when": "terminalFocus && terminalProcessSupported" }, // C-x b = switch-to-buffer
{ "key": "ctrl+x h", "command": "workbench.action.terminal.sendSequence", "args": { "text": "\u0018h" }, "when": "terminalFocus && terminalProcessSupported" }, // C-x h = mark-whole-buffer
{ "key": "ctrl+x ctrl+n", "command": "workbench.action.terminal.sendSequence", "args": { "text": "\u0018\u000e" }, "when": "terminalFocus && terminalProcessSupported" }, // C-x C-n = set-goal-column
{ "key": "ctrl+/", "command": "workbench.action.terminal.sendSequence", "args": { "text": "\u001f" }, "when": "terminalFocus && terminalProcessSupported" }, // C-/ = undo
{ "key": "ctrl+x u", "command": "workbench.action.terminal.sendSequence", "args": { "text": "\u0018u" }, "when": "terminalFocus && terminalProcessSupported" }, // C-x u = undo
{ "key": "ctrl+shift+/", "command": "workbench.action.terminal.sendSequence", "args": { "text": "\u001f" }, "when": "terminalFocus && terminalProcessSupported" }, // C-? = undo (same as C-/)
{ "key": "ctrl+shift+-", "command": "workbench.action.terminal.sendSequence", "args": { "text": "\u001f" }, "when": "terminalFocus && terminalProcessSupported" }, // C-_ = undo
{ "key": "alt+;", "command": "workbench.action.terminal.sendSequence", "args": { "text": "\u001b;" }, "when": "terminalFocus && terminalProcessSupported" }, // M-; = comment-dwim
{ "key": "alt+g g", "command": "workbench.action.terminal.sendSequence", "args": { "text": "\u001bgg" }, "when": "terminalFocus && terminalProcessSupported" }, // M-g g = goto-line
{ "key": "ctrl+g", "command": "workbench.action.terminal.sendSequence", "args": { "text": "\u0007" }, "when": "terminalFocus && terminalProcessSupported" }, // C-g = keyboard-quit
{ "key": "ctrl+x ctrl+c", "command": "workbench.action.terminal.sendSequence", "args": { "text": "\u0018\u0003" }, "when": "terminalFocus && terminalProcessSupported" } // C-x C-c = save-buffers-kill-terminal
]
@HackingGate
Copy link
Author

HackingGate commented May 19, 2025

Refer the doc for how to custom key bindings for Visual Studio Code.
https://code.visualstudio.com/docs/configure/keybindings#_advanced-customization

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