vscode-simple-vim icon indicating copy to clipboard operation
vscode-simple-vim copied to clipboard

Custom key to enter normal mode

Open Oliver-Fish opened this issue 7 years ago • 2 comments

Hi,

Would it be possible to add a setting to define a new key sequence to enter normal mode? In my current vim workflow I like to use 'jk' and I know quite a few people use variations upon this.

Thanks

Oliver-Fish avatar Jul 24 '18 16:07 Oliver-Fish

Thanks for the suggestion! I know this is something that is fairly common in Vim, but unfortunately I don't think there's a good way to implement this in a VSCode extension. So for now you'll have to use VSCode's native keybindings for this. That means jk isn't practical because VSCode's keybindings aren't smart enough to type the j character if it's not followed by k. But you could do something like Ctrl+j Ctrl+k instead. Just add this to your keybindings.json:

{
    "key": "ctrl+j ctrl+k",
    "command": "extension.simpleVim.escapeKey",
    "when": "editorTextFocus"
}

I don't want to support this in this extension for two reasons. First, it's really a feature request for VSCode's keybindings. Second, in order to support this I'd have to intercept every keypress in insert mode and then forward any that aren't jk to VSCode. That's hacky and I think it would cause bugs. At the moment, insert mode doesn't intercept any keys, it just uses the normal VSCode keybinding system to listen for the Escape key (similar to the code snippet above). So insert mode is just vanilla VSCode, and I'd like to keep it that way.

jpotterm avatar Jul 24 '18 17:07 jpotterm

@Oliver-Fish you have this feature here:

"vim.insertModeKeyBindings": [
    {
      "before": ["j", "k"],
      "after": ["<Esc>"]
    }
  ]

ericdouglas avatar Aug 18 '18 11:08 ericdouglas