Vim: Visual Mode doesn't respect overridden keybindings

Created on 16 Jul 2018  路  4Comments  路  Source: VSCodeVim/Vim

Describe the bug
The visualModeKeyBindings{NonRecursive} option ignores some motion keybindings.

To Reproduce

  1. Open settings
  2. Define a custom keybinding inside the file, like this:
  "vim.visualModeKeyBindingsNonRecursive": [
    {
      "before": ["H"],
      "after": ["^"],
    },
    {
      "before": ["L"],
      "after": ["$"],
    },
  ]
  1. Save the file
  2. Reload VS Code
  3. Open settings
  4. Find vim.visualModeKeyBindingsNonRecursive and position the cursor over the dot (.) after vim
  5. Enter Visual Mode
  6. Press L

Expected behavior
Select from the position of the cursor until the end of the line in visual mode (same as using the $ motion as stated in the config)

Actual behaviour
Selects from the position of the cursor until the end of the viewport (L's default behaviour, instead of the one defined in the config file)

Environment

  • Extension Name: vim
  • Extension Version: 0.15.0
  • OS Version: Darwin x64 16.7.0
  • VSCode version: 1.25.1
{
    "activationTimes": {
        "startup": true,
        "codeLoadingTime": 260,
        "activateCallTime": 5,
        "activateResolvedTime": 82,
        "activationEvent": "*"
    }
}

Additional context

I can confirm that using vnoremap L $ in regular vim behaves as expected. Other visual mode commands (such as y$) do work, but __only__ after I've pressed v to enter visual mode _and pressed another key that's not escape). This seems to be a different bug.

statuduplicate

Most helpful comment

I'd be happy to help in any way I can, although my knowledge of the internals of this extension and TypeScript in general is very small 馃槄

A couple of those issues does shed some light about what the issue is.

In https://github.com/VSCodeVim/Vim/issues/2131#issuecomment-343228374 and https://github.com/VSCodeVim/Vim/issues/1835#issuecomment-392646876, you can see that the workaround is pressing another key, because visual mode keybinds don't work otherwise. I think this is because when visual mode is turned on, v is passed as a chord of sorts.

screen shot 2018-07-16 at 7 50 57 pm

See that extra v after --VISUAL--? It's the same if you had pressed d in normal mode for example. It's expecting another keybinding. That's a bug.

It would also seem that this has been happening for a while.

As a workaround:

  "vim.normalModeKeyBindings": [
    // Workaround: Visual Mode chord bug
    // https://github.com/VSCodeVim/Vim/issues/2842
    {
      "before": ["v"],
      "after": ["v", "l", "h"]
    },

All 4 comments

Actually, a significant percentage of issues is regarding remapping of key bindings.

Perhaps we can pool resources to work on a release which would resolve all of them in 1 shot!

I'd be happy to help in any way I can, although my knowledge of the internals of this extension and TypeScript in general is very small 馃槄

A couple of those issues does shed some light about what the issue is.

In https://github.com/VSCodeVim/Vim/issues/2131#issuecomment-343228374 and https://github.com/VSCodeVim/Vim/issues/1835#issuecomment-392646876, you can see that the workaround is pressing another key, because visual mode keybinds don't work otherwise. I think this is because when visual mode is turned on, v is passed as a chord of sorts.

screen shot 2018-07-16 at 7 50 57 pm

See that extra v after --VISUAL--? It's the same if you had pressed d in normal mode for example. It's expecting another keybinding. That's a bug.

It would also seem that this has been happening for a while.

As a workaround:

  "vim.normalModeKeyBindings": [
    // Workaround: Visual Mode chord bug
    // https://github.com/VSCodeVim/Vim/issues/2842
    {
      "before": ["v"],
      "after": ["v", "l", "h"]
    },

Closing as duplicate of #1835

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AndersenJ picture AndersenJ  路  3Comments

lucastheisen picture lucastheisen  路  3Comments

typeoneerror picture typeoneerror  路  3Comments

cckowin picture cckowin  路  3Comments

ACollectionOfAtoms picture ACollectionOfAtoms  路  3Comments