VSCodeVim / VSCodeVim/Vim

Add context for plugcs to customize keyboard shortcuts

Open
#8,246 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Is your feature request related to a problem? Please describe.
I want an easy way to switch between diffs in the editor.

Describe the solution you'd like
I added this to my keybindings.json:

{
    "key": "] c",
    "command": "workbench.action.editor.nextChange",
    "when": "editorTextFocus && !textCompareEditorActive && vim.mode == 'Normal'"
},
{
    "key": "[ c",
    "command": "workbench.action.editor.previousChange",
    "when": "editorTextFocus && !textCompareEditorActive && vim.mode == 'Normal'"
},

which mirrors the default vim bindings

3. Jumping to diffs					*jumpto-diffs*

Two commands can be used to jump to diffs:

								*[c*
	[c		Jump backwards to the previous start of a change.
			When a count is used, do it that many times.

								*]c*
	]c		Jump forwards to the next start of a change.
			When a count is used, do it that many times.

It is an error if there is no change for the cursor to move to.

Additional context
The downside to this is that it breaks cs]) (change surrounding square brackets to parens).

I tried using https://code.visualstudio.com/api/references/when-clause-contexts#inspect-context-keys-utility but there's nothing relevant in the vim section that I can use to exclude the keybindings during plugcs. (e.g. && !vim.plugcsActive)

See available json context

It seems like vscode is aware when I'm in the middle of a cs plugcs call, because the status line changes:

image

but I don't know how to use such info in a keybinding.

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

Start with the VS Code when-clause context documentation and the issue's keybindings.json examples, then inspect how the extension exposes context keys while processing plugcs such as cs]) and updates the status line. Confirm the relevant context is available to keybindings and document or test that diff-navigation shortcuts are excluded during plugcs without breaking surrounding changes.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.