Vim icon indicating copy to clipboard operation
Vim copied to clipboard

normal mode keybindings isn't working.

Open cognitiveRobot opened this issue 1 year ago • 4 comments

I am trying to bind keys using leader key. I added :vsplit in Normal mode and insert mode for testing. The binding is working in insert mode but not working in the normal mode.

 "vim.leader": "<Space>",
  "vim.normalModeKeyBindingsNonRecursive": [
      {
          "before": ["leader", "v"],
          "commands": [":vsplit"]
      }
    ],
  "vim.insertModeKeyBindings": [
   {
      "before": ["leader", "v"],
      "commands": [":vsplit"]
  },
  ],
  • Extension (VsCodeVim) version: 1.29.0
  • VSCode version: 1.99.3
  • OS: Windows 10

Please note my code base is in a remote machine running Ubuntu 22.04.5. I am using ssh on windows VSCode.

Can you please help?

cognitiveRobot avatar Apr 30 '25 02:04 cognitiveRobot

Your formatting is a bit odd. Not sure if it's a parsing issue, but unlikely to be. Wouldn't hurt running a formatter over your settings.json (backup first)

JoshPaulie avatar Apr 30 '25 17:04 JoshPaulie

when you say "leader" in the configuration, its supposed to be "", otherwise you would have to type l e a d e r v for the command to work

RodrigoScola avatar May 01 '25 15:05 RodrigoScola

you should use <leader> instead of leader in your "before" because leader is a special key

Liuliuliu7 avatar May 03 '25 14:05 Liuliuliu7

I was struggling with this problem as well. A specific piece of code in my keybindings.json file was interfering with the functionality of the space key. Instead of being interpreted as the leader key, it was being processed by VSCode. So I looked for all instances and commented them out.

// {
//     "key": "space d",
//     "command": "extension.vim_ctrl+d",
//     "when": "editorTextFocus && vim.active && vim.use<C-f> && !inDebugRepl && vim.mode != 'Insert'"
// },

Additionally, I have defined the leader key in my settings.json as follows:

"vim.leader": "<space>",

The commands that utilize the leader key are set up like this:

{
    "before": ["<leader>", "v"],
    "commands": ["workbench.action.splitEditorRight"]
},

Otherwise, maybe someone in #4899 has another solution for you

m1zp avatar Oct 15 '25 13:10 m1zp