Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In VSCode, Exit Vim Insert Mode on Save

I use VSCode with the VSCodeVim extension. When in Insert Mode, I can press "CMD-S" to save. When I do, I would also like to exit Insert Mode automatically instead of pressing "ESC" as well.

Is this possible?

like image 429
earllee Avatar asked Mar 01 '18 12:03

earllee


1 Answers

I was looking for a solution similar to this issue as well.

It appears that multiple commands cannot be mapped to key bindings in vscode; however, I've found an extension, macros, that let's you do this.

If you use the below steps with the macros extension, I believe that you'll have the solution you're looking for, until vscode implements something to address this feature request.

Step one, edit user settings with the below:

"macros": {
    "saveAndExitVimInsertMode": [
        "workbench.action.files.save",
        "extension.vim_escape"
    ]
}

Step two, edit keyboard bindings:

    {
    "key": "cmd+s",
    "command": "macros.saveAndExitVimInsertMode"
    }
like image 84
Kim Avatar answered Sep 19 '22 23:09

Kim