Skip to main content

VSCode の キーバインディング設定

方針

Win/Mac 共通

  • ウィンドウ分割
    • vim 風で C-w v などで操作(VSCode にもあるが覚えられなくて)
  • 単語削除 (Xcode 風の CamelCase 対応)
    • Ctrl + BackSpace
    • settings.jsoneditor.wordSegmenterLocales: ["ja"] とセットだと快適
  • 行頭への移動
    • Ctrl + A はインデント後の先頭 → 先頭 の順
  • タブ移動
    • エディタ、Terminal とも Ctrl + [ / Ctrl + ] で移動可にする
  • 開いているファイルを Explorer に表示
    • Cmd + Shift + E

Windows 固有

  • Emacs 風のカーソル移動操作
    • Ctrl + K だけは 2 回押すという操作で妥協
  • Emacs 風にしたことで使えなくなったキー
    • Alt に逃がす : Ctrl + AAlt + A など
    • Windows の Alt は、たいてい Mac の Cmd の位置にあるので少しだけ馴染みやすい
  • Mac と差のあるキー操作
    • Ctrl + Shift + @ で Terminal が新しく作成されるのは回避。Toggleとする

Mac 固有

  • 基本なし

設定例

設定例 (Mac)
keybindings.json
[
// ------------------------------------------------------------------------------------------
// Common (Win/Mac)

// Vim-like window ops
{ "key": "ctrl+w" , "command": "-workbench.action.switchWindow" },
{ "key": "ctrl+w v" , "command": "workbench.action.splitEditor" , "when": "!terminalFocus" },
{ "key": "ctrl+w ctrl+v" , "command": "workbench.action.splitEditor" , "when": "!terminalFocus" },
{ "key": "ctrl+w s" , "command": "workbench.action.splitEditorOrthogonal" , "when": "!terminalFocus" },
{ "key": "ctrl+w ctrl+s" , "command": "workbench.action.splitEditorOrthogonal" , "when": "!terminalFocus" },
{ "key": "ctrl+w c" , "command": "workbench.action.closeActiveEditor" , "when": "!terminalFocus" },
{ "key": "ctrl+w ctrl+c" , "command": "workbench.action.closeActiveEditor" , "when": "!terminalFocus" },
{ "key": "ctrl+w k" , "command": "workbench.action.focusAboveGroup" , "when": "!terminalFocus" },
{ "key": "ctrl+w ctrl+k" , "command": "workbench.action.focusAboveGroup" , "when": "!terminalFocus" },
{ "key": "ctrl+w j" , "command": "workbench.action.focusBelowGroup" , "when": "!terminalFocus" },
{ "key": "ctrl+w ctrl+j" , "command": "workbench.action.focusBelowGroup" , "when": "!terminalFocus" },
{ "key": "ctrl+w h" , "command": "workbench.action.focusLeftGroup" , "when": "!terminalFocus" },
{ "key": "ctrl+w ctrl+h" , "command": "workbench.action.focusLeftGroup" , "when": "!terminalFocus" },
{ "key": "ctrl+w l" , "command": "workbench.action.focusRightGroup" , "when": "!terminalFocus" },
{ "key": "ctrl+w ctrl+l" , "command": "workbench.action.focusRightGroup" , "when": "!terminalFocus" },
{ "key": "ctrl+w w" , "command": "workbench.action.focusNextGroup" , "when": "!terminalFocus" },
{ "key": "ctrl+w ctrl+w" , "command": "workbench.action.focusNextGroup" , "when": "!terminalFocus" },
{ "key": "ctrl+w shift+-" , "command": "workbench.action.evenEditorWidths" , "when": "!terminalFocus" },
{ "key": "ctrl+w =" , "command": "workbench.action.evenEditorWidths" , "when": "!terminalFocus" },
{ "key": "alt+w" , "command": "workbench.action.closeActiveEditor" , "when": "!terminalFocus" }, // use 'Alt' insted (mainly for mac)

// Word delete (also effective on camelCase)
{ "key": "ctrl+backspace", "command": "deleteWordPartLeft", "when": "textInputFocus && !editorReadonly" },


// ------------------------------------------------------------------------------------------
// Mac

// TabFocus on Terminal
{ "key": "shift+cmd+[" , "command": "workbench.action.terminal.focusPrevious" , "when": "terminalFocus && terminalProcessSupported" },
{ "key": "shift+cmd+]" , "command": "workbench.action.terminal.focusNext" , "when": "terminalFocus && terminalProcessSupported" },

// Reveal the active file in the Explorer
{ "key": "cmd+shift+e", "command": "workbench.files.action.showActiveFileInExplorer", "when": "inputFocus" },

// To beginning-of-line, but stops at indent first
{ "key": "ctrl+a" , "command": "cursorHome" , "when": "editorTextFocus" },
]
設定例 (Windows)
keybindings.json
[
// ------------------------------------------------------------------------------------------
// Common (Win/Mac)

// Vim-like window ops
{ "key": "ctrl+w" , "command": "-workbench.action.switchWindow" },
{ "key": "ctrl+w v" , "command": "workbench.action.splitEditor" , "when": "!terminalFocus" },
{ "key": "ctrl+w ctrl+v" , "command": "workbench.action.splitEditor" , "when": "!terminalFocus" },
{ "key": "ctrl+w s" , "command": "workbench.action.splitEditorOrthogonal" , "when": "!terminalFocus" },
{ "key": "ctrl+w ctrl+s" , "command": "workbench.action.splitEditorOrthogonal" , "when": "!terminalFocus" },
{ "key": "ctrl+w c" , "command": "workbench.action.closeActiveEditor" , "when": "!terminalFocus" },
{ "key": "ctrl+w ctrl+c" , "command": "workbench.action.closeActiveEditor" , "when": "!terminalFocus" },
{ "key": "ctrl+w k" , "command": "workbench.action.focusAboveGroup" , "when": "!terminalFocus" },
{ "key": "ctrl+w ctrl+k" , "command": "workbench.action.focusAboveGroup" , "when": "!terminalFocus" },
{ "key": "ctrl+w j" , "command": "workbench.action.focusBelowGroup" , "when": "!terminalFocus" },
{ "key": "ctrl+w ctrl+j" , "command": "workbench.action.focusBelowGroup" , "when": "!terminalFocus" },
{ "key": "ctrl+w h" , "command": "workbench.action.focusLeftGroup" , "when": "!terminalFocus" },
{ "key": "ctrl+w ctrl+h" , "command": "workbench.action.focusLeftGroup" , "when": "!terminalFocus" },
{ "key": "ctrl+w l" , "command": "workbench.action.focusRightGroup" , "when": "!terminalFocus" },
{ "key": "ctrl+w ctrl+l" , "command": "workbench.action.focusRightGroup" , "when": "!terminalFocus" },
{ "key": "ctrl+w w" , "command": "workbench.action.focusNextGroup" , "when": "!terminalFocus" },
{ "key": "ctrl+w ctrl+w" , "command": "workbench.action.focusNextGroup" , "when": "!terminalFocus" },
{ "key": "ctrl+w shift+-" , "command": "workbench.action.evenEditorWidths" , "when": "!terminalFocus" },
{ "key": "ctrl+w =" , "command": "workbench.action.evenEditorWidths" , "when": "!terminalFocus" },
{ "key": "alt+w" , "command": "workbench.action.closeActiveEditor" , "when": "!terminalFocus" }, // use 'Alt' insted (mainly for mac)

// Word delete (also effective on camelCase)
{ "key": "ctrl+backspace", "command": "deleteWordPartLeft", "when": "textInputFocus && !editorReadonly" },

// ------------------------------------------------------------------------------------------
// Windows

// TabFocus on Terminal
{ "key": "ctrl+shift+oem_4" , "command": "workbench.action.terminal.focusPrevious" , "when": "terminalFocus && terminalProcessSupported" },
{ "key": "ctrl+shift+oem_6" , "command": "workbench.action.terminal.focusNext" , "when": "terminalFocus && terminalProcessSupported" },

// Reveal the active file in the Explorer
{ "key": "ctrl+shift+e", "command": "workbench.files.action.showActiveFileInExplorer", "when": "inputFocus" },

// Emacs-like cursor ops on Windows
{ "key":"ctrl+f" , "command": "cursorRight" , "when":"editorTextFocus" },
{ "key":"ctrl+b" , "command": "cursorLeft" , "when":"editorTextFocus" },
{ "key":"ctrl+n" , "command": "cursorDown" , "when":"editorTextFocus" },
{ "key":"ctrl+p" , "command": "cursorUp" , "when":"editorTextFocus" },
{ "key":"ctrl+a" , "command": "cursorHome" , "when":"editorTextFocus" },
{ "key":"ctrl+e" , "command": "cursorEnd" , "when":"editorTextFocus" },
{ "key":"ctrl+d" , "command": "deleteRight" , "when":"editorTextFocus" },
{ "key":"ctrl+h" , "command": "deleteLeft" , "when":"editorTextFocus" },
{ "key":"ctrl+k ctrl+k" , "command": "deleteAllRight" , "when":"editorTextFocus" },

// Ctrl is used as emacs-like cursor ops, then use 'Alt' instead
{ "key": "alt+p" , "command": "workbench.action.quickOpenNavigateNextInFilePicker" , "when": "inFilesPicker && inQuickOpen" },
{ "key": "alt+p" , "command": "workbench.action.quickOpen" },
{ "key": "alt+f" , "command": "actions.find" },
{ "key": "alt+b" , "command": "markdown.extension.editing.toggleBold", "when": "editorTextFocus && !editorReadonly && editorLangId == 'markdown'" },
{ "key": "alt+n" , "command": "workbench.action.files.newUntitledFile" },
{ "key": "shift+alt+n" , "command": "workbench.action.newWindow" },
{ "key": "alt+a" , "command": "editor.action.selectAll", "when": "textInputFocus" },
{ "key": "alt+a" , "command": "editor.action.webvieweditor.selectAll", "when": "!editorFocus && !inputFocus && activeEditor == 'workbench.editor.htmlPreviewPart'" },
{ "key": "alt+s" , "command": "workbench.action.files.save", "when": "textInputFocus" },
{ "key": "alt+c" , "command": "editor.action.clipboardCopyAction", "when": "textInputFocus" },
{ "key": "alt+v" , "command": "editor.action.clipboardPasteAction", "when": "textInputFocus" },
// { "key": "alt+z" , "command": "undo" }, // Don't use 'Alt+Z' for undo, because it's used for toggle word wrap.
// { "key": "alt+shift+z" , "command": "redo" },

// Mac-like ops on Windows
{ "key": "alt+down" , "command": "cursorBottom" , "when": "textInputFocus" },
{ "key": "shift+alt+down" , "command": "cursorBottomSelect" , "when": "textInputFocus" },
{ "key": "alt+up" , "command": "cursorTop" , "when": "textInputFocus" },
{ "key": "shift+alt+up" , "command": "cursorTopSelect" , "when": "textInputFocus" },
{ "key": "ctrl+shift+[" , "command": "workbench.action.previousEditor" , "when": "editorTextFocus" },
{ "key": "ctrl+shift+oem_4" , "command": "workbench.action.previousEditor" , "when": "editorTextFocus" },
{ "key": "ctrl+shift+]" , "command": "workbench.action.nextEditor" , "when": "editorTextFocus" },
{ "key": "ctrl+shift+oem_6" , "command": "workbench.action.nextEditor" , "when": "editorTextFocus" },
{ "key": "ctrl+shift+@" , "command": "workbench.action.terminal.toggleTerminal" , "when": "terminal.active" },
{ "key": "ctrl+shift+oem_3" , "command": "workbench.action.terminal.toggleTerminal" , "when": "terminal.active" },
]