visual-studio-codeautosavevscodevim

How to auto save file in VSCode on Esc when using Vim extension?


I wonder, how can I save current file automatically in VSCode after leaving insert mode in Vim by pressing Esc key?


Solution

  • Replacing <Esc> with <Esc>:w<Enter> works, but this is probably a slightly more elegant solution (if you have other save commands you'd like to run for example).

        "vim.insertModeKeyBindingsNonRecursive": [
        {
            "before": [
                "<Esc>"
            ],
            "after": [
                "<Esc>"
            ],
            "commands": [
                "workbench.action.files.save"
            ]
        }
    ],