VSCodeVim / VSCodeVim/Vim

Use `when` clause in keybinding overrides

Open
#1,372 7 comments 25 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area/remap kind/feature
Dominant language
TypeScript
Stars
15.2k
Forks
1.5k
Avg merge
3d 18h
Merged PRs (30d)
6

Description

I would love to use something like this:

"vim.insertModeKeyBindings": [
       {
           "before": ["ctrl", "p"],
           "after": [],
           "commands": [
               {
                   "command": "editor.action.triggerSuggest",
                   "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly && !suggestWidgetVisible"
               },
               {
                   "command": "selectPrevSuggestion",
                   "when": "editorTextFocus && suggestWidgetVisible"
               }
           ]
       },
       {
           "before": ["ctrl", "n"],
           "after": [],
           "commands": [
               {
                   "command": "editor.action.triggerSuggest",
                   "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly && !suggestWidgetVisible"
               },
               {
                   "command": "selectNextSuggestion",
                   "when": "editorTextFocus && suggestWidgetVisible"
               }
           ]
       }
  ]

Use-case

Demonstrates behavior of Ctrl + P in normal and insert modes.

Normal mode

Works without change - lets me find and open a file in a project.

Insert mode

When I do not have suggestion window visible, it will trigger the suggestion window to be visible.

When I do have suggestion window visible, it will go to previous suggestion.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files, tests, or entry points are named. Start by locating the keybinding override configuration and its command-dispatch handling, then determine how existing keybindings are evaluated. Done means command entries can include when clauses so the appropriate command runs depending on editor and suggestion-widget context.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, vim, vscode
Domain
developer-experience, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.