Vim icon indicating copy to clipboard operation
Vim copied to clipboard

Cannot remap a sequence of 3 keys or more

Open cBournhonesque opened this issue 1 year ago • 1 comments

Describe the bug My config has

 "vim.normalModeKeyBindingsNonRecursive": [
      {
          "before": ["<leader>", "z", "o"],
          "after": [],
          "commands": [
              {
                  "command": "workbench.action.closeOtherEditors"
              }
          ]
      },
]

When I press space z o, the space z is first handled separately and does nothing, and then o is handled, which adds a new line. Instead I would like my newly-defined command to work.

My trace logs:

2025-03-19 14:36:50.783 [debug] Handling key: <space>
2025-03-19 14:36:50.783 [trace] trying to find matching remap. keys= . mode=Normal. keybindings=normalModeKeyBindingsMap.
2025-03-19 14:36:50.783 [trace] normalModeKeyBindingsMap. potential remap found. waiting for other key or timeout to finish.
2025-03-19 14:36:50.784 [trace] handleKeyEvent('<space>') took 1ms
2025-03-19 14:36:51.059 [debug] Handling key: z
2025-03-19 14:36:51.059 [trace] trying to find matching remap. keys= ,z. mode=Normal. keybindings=normalModeKeyBindingsMap.
2025-03-19 14:36:51.059 [trace] key= ,z. keySlice= z.
2025-03-19 14:36:51.059 [trace] normalModeKeyBindingsMap. potential remap broken. resending keys without allowing a potential remap on first key. keys= ,z
2025-03-19 14:36:51.060 [debug] Remapping to  ,z
2025-03-19 14:36:51.060 [debug] Handling key: <space>
2025-03-19 14:36:51.060 [trace] trying to find matching remap. keys= . mode=Normal. keybindings=normalModeKeyBindingsMap.
2025-03-19 14:36:51.065 [trace] Setting key='vim.command' to value='<leader>'
2025-03-19 14:36:51.065 [trace] handleKeyEvent('<space>') took 6ms
2025-03-19 14:36:51.068 [debug] Handling key: z
2025-03-19 14:36:51.068 [trace] Setting key='vim.command' to value='<leader>z'
2025-03-19 14:36:51.068 [trace] Setting key='vim.command' to value=''
2025-03-19 14:36:51.068 [trace] handleKeyEvent('z') took 2ms
2025-03-19 14:36:51.069 [trace] handleKeyEvent('z') took 10ms
2025-03-19 14:36:51.344 [debug] Handling key: o
2025-03-19 14:36:51.345 [trace] trying to find matching remap. keys=o. mode=Normal. keybindings=normalModeKeyBindingsMap.
2025-03-19 14:36:51.346 [trace] Setting key='vim.command' to value='o'

Expected behavior I would have expected my command space z o to apply the vscode command i defined in the remap.

  • Extension (VsCodeVim) version: 1.29.0
  • VSCode version: 1.85.2
  • OS: MacPro M2

Additional context

I tried to instead setup keybindings in keybindings.json to do what I want. But it seems like if I define a keybinding there that starts with my vim <leader> key, the vscode-vim bindings stop working entirely.

cBournhonesque avatar Mar 19 '25 18:03 cBournhonesque

the configuration file that this should be setup is in your settings.json, and could you try updating your configuration to

 "vim.normalModeKeyBindingsNonRecursive": [
      {
          "before": ["<leader>", "z", "o"],
          "commands": [
              "workbench.action.closeOtherEditors"
              
          ]
      },
]

the not working part might be because theres an empty arrray on after or because the commands is an string array, dont know if they accept an object in the array, but i know that a string they do

also if that doesnt work aswell you could try with "vim.normalModeKeyBindings"

RodrigoScola avatar May 01 '25 15:05 RodrigoScola