VSCodeVim does not allow single definitions of keybindings for multiple keybinding types
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 15.2k
- Forks
- 1.5k
- Avg merge
- 3d 18h
- Merged PRs (30d)
- 6
Description
The Issue
We have normalModeKeyBindingsNonRecursive for normal mode keybindings, visualModeKeyBindingsNonRecursive for visual mode keybindings. But there's no way to define a keybinding that applies to 'both normal and visual modes'. Instead, it has to be duplicated in each of the keybinding arrays.
An Example
I want <leader>p to pin the current file, and I want it to work in normal and visual modes. In my .vimrc I'd have something like:
noremap <leader>p pin_function
But for VSCodeVim I need:
"vim.normalModeKeyBindingsNonRecursive": [
{
"before": [ "<leader>", "p" ],
"commands": [ "workbench.action.pinEditor" ]
},
],
"vim.visualModeKeyBindingsNonRecursive": [
{
"before": [ "<leader>", "p" ],
"commands": [ "workbench.action.pinEditor" ]
},
],
Solution Idea
Introduce a new keybinding interface in config, vim.keybindings, to which you supply:
a) A boolean that defines whether the keybinding is recursive,
b) An array of characters that specify the modes the keybinding should apply to (e.g. n, v)
c) The keybinding
For example:
"vim.keybindings": [
{
"recursive": true,
"modes": ["n", "v"],
"before": [ "<leader>", "p" ],
"commands": [ "workbench.action.unpinEditor" ]
}]
Another idea would be to supply the mapping definition to the keybinding (e.g. "definition": "noremap") and have the VSCodeVim extension work out whether it's recursive and what modes it should apply to.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the existing normalModeKeyBindingsNonRecursive and visualModeKeyBindingsNonRecursive configuration handling and comparing their recursive and mode-specific behavior. Define how a shared vim.keybindings configuration should represent modes and recursion, then verify that one binding can apply to both normal and visual modes without requiring duplication while preserving existing configuration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100