毎回<Esc>を押しに行くのが面倒とお思いのあなたへ(VSCode, Vim)

jjを割り当てる

(Ctrl+Shift+P) でコマンドパレットを開き,Preferences: Open Settings (JSON)の中に以下を書く.

{
    "editor.tabSize": 4,
    "editor.detectIndentation": false,
    "files.encoding": "utf8",

    "vim.insertModeKeyBindings": [
        {
            "before": ["j", "j"],
            "after": ["<Esc>"]
        }
    ] 
}

ctrl + ;でターミナルとエディタを切り替える

(Ctrl+Shift+P) でコマンドパレットを開き,Preferences: Open Keyboard Shortcuts Filesの中に以下を書く.

[    
    {
       "key": "Ctrl+j",
       "command": "extension.vim_escape",
       "when": "editorTextFocus && vim.active && !inDebugRepl"
    },
    { 
        "key": "ctrl+;", 
        "command": "workbench.action.terminal.focus"
    },
    { 
        "key": "ctrl+;", 
        "command": "workbench.action.focusActiveEditorGroup", 
        "when": "terminalFocus"
    },
    {
        "key": "ctrl+w",
        "command": "workbench.action.closeActiveEditor",
        "when": "editorTextFocus"
    },
    {
        "key": "ctrl+shift+right",
        "command": "workbench.action.moveEditorToNextGroup",
        "when": "editorTextFocus"
    },
    {
        "key": "ctrl+shift+left",
        "command": "workbench.action.moveEditorToPreviousGroup",
        "when": "editorTextFocus"
    },
    {
        "key": "ctrl+shift+tab",
        "command": "workbench.action.previousEditor",
        "when": "editorTextFocus"
    },
    {
        "key": "ctrl+tab",
        "command": "workbench.action.nextEditor",
        "when": "editorTextFocus"
    },
    {
        "key": "tab",
        "command": "tab",
        "when": "editorTextFocus"
    },
    {
        "key": "ctrl+shift+c",
        "command": "editor.action.clipboardCopyAction",
        "when": "!terminalFocus"
    }
]

(おまけ)vscodeでよく使うショートカットキーメモ

  • エクスプローラとエディタの切り替え Ctrl + Shift + E
  • エディタの分割 Ctrl + \
  • エディタグループの切り替え(なければ作成) Ctrl + 数字
  • アクティブタブを隣のエディタグループへ移動 Ctrl + Alt + ←→
  • アクティブなタブを終了 Ctrl + w