0

I use VSCode Neovim plugin, and I would like to use "Ctrl+S" key for "save this file, and then switch to normal mode", which visually change the cursor style from "thin" to "solid".

My vim/nvim config file is with:

"--- ctrl + s  saving
noremap  <silent> <C-S>  :update<CR>
vnoremap <silent> <C-S>  <C-C>:update<CR>
inoremap <silent> <C-S>  <C-O>:update<CR><ESC>

But in VSCode, edit some words, then press "Ctrl+S" just save the file, didn't switch to normal mode. i.e. the <C-O>:update<CR><ESC> is not executed. How can I let it be executed?

Tried solution: In VSCode, Exit Vim Insert Mode on Save

settings.json:

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

keybindings.json:

    {
        "key": "ctrl+s",
        //"command": "workbench.action.files.save"
        "command": "macros.saveAndExitVimInsertMode"
    },

But still not working.

romainl
  • 186,200
  • 21
  • 280
  • 313
ChrisZZ
  • 1,521
  • 2
  • 17
  • 24

1 Answers1

0

Resolved by the following config in setttings.json:

    "macros": {
        "saveAndExitVimInsertMode": [
            "workbench.action.files.save",
            //"extension.nvim_escape" // not working
            "vscode-neovim.escape" // working
        ]
    },

Reference: https://github.com/vscode-neovim/vscode-neovim/issues/74#issuecomment-563214553

ChrisZZ
  • 1,521
  • 2
  • 17
  • 24