Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vim.mode == 'Normal' in key binding is triggering in replace mode #7256

Closed
andrewplummer opened this issue Nov 14, 2021 · 5 comments
Closed

Comments

@andrewplummer
Copy link

I have the following key binding:

    {
        "key": "shift+l",
        "command": "workbench.action.nextEditorInGroup",
        "when": "vim.mode == 'Normal'"
    },

to use vim keys to switch editors. This works perfectly, however I noticed that when I hit r to replace a character thenshift+l this shortcut will be triggered. I am expecting vim to not be in Normal mode in this case but instead Replace mode (or possibly CommandlineInProgressMode or OperatorPendingMode although I'm not exactly if either or none of these apply as the documentation doesn't really make clear when these modes are triggered).

Am I doing something wrong here?

  • Extension (VsCodeVim) version: v1.21.10
  • VSCode version: 1.62.2 (Universal)
  • OS: OSX 12.0.1
@w-cantin
Copy link
Contributor

w-cantin commented Nov 19, 2021

Hello,

From experience remapping vim keys in keybindings.json instead of the recommended way in settings.json is kind of hit or miss. A better way to proceed is to trigger regular vscode commands using the "vim.normalModeKeyBindings" command in settings.json. Here is what might look like:

  "vim.normalModeKeyBindingsNonRecursive": [
      { "before": ["L"], "commands": ["workbench.action.nextEditorInGroup"] },
]

I hope it helped

Note that I used the NonRecursive command just by habit but in this case it will not change the end result.

@andrewplummer
Copy link
Author

Cool that seems to have worked. Also FWIW normalModeKeyBindingsNonRecursive doesn't seem to be a recognized setting (yellow squiggles suggesting it's not valid) although it works fine. Anyway thanks!

@w-cantin
Copy link
Contributor

Do the yellow squiggle appear because it is a duplicated setting? If you hover your mouse over the squiggle what does it say?

@andrewplummer
Copy link
Author

I am stupid... indeed you are right :)
No issues here!

@fedoraiver
Copy link

actually r is in the normal mode,replace mode you have to press R

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants