5

I'm trying to bind ":W" editor command to save the file just like ":w". I make a lot of this typos.

The vim plugin is: https://marketplace.visualstudio.com/items?itemName=vscodevim.vim

This settings.json code doesn't work:

"vim.normalModeKeyBindingsNonRecursive": [
  {
    "before": [":","W"],
    "commands": [
      "workbench.action.files.save"
    ]
  }
]
1
  • 2
    command mode mappings do not seem to be possible at the moment in vs code vim. see here github.com/VSCodeVim/Vim/issues/2903 Commented Nov 22, 2018 at 7:33

1 Answer 1

1

Unfortunately this is not possible in vs code vim, but I ended up doing what bsaf suggested here and rebound : to ; so that I wouldn't accidentally be holding shift down while pressing w, which doesn't solve the problem you asked but it does solve the problem you mentioned in your post. You can do this by adding this to your settings.json file:

"vim.normalModeKeyBindings": [
  {
     "before": [";"],
     "after": [":"]
   }
]

You can still use : as normal, but now ; will also allow you to run editor commands.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.