VSCodeVim / VSCodeVim/Vim

Keys after commands in key bindings

Open
#9,029 2 comments 1 reaction 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'm trying to define nice key bindings for LaTeX Workshop's various commands. The one I'm working on now is latex-workshop.wrap-env, which wraps the selection in \begin{}...\end{} and puts multiple cursors on the two }s so you can type the environment name. This is naturally an operation for Visual Mode, but afterwards I want to be in Insert Mode. The only way I know to do that is to type <Esc>i.

Describe the solution you'd like
I'd like to bind keys to execute a command and then simulate some keystrokes.

Describe alternatives you've considered
It seems that after keys are executed before commands instead of after, which is when I want these keys to execute. This is what I tried:

    "vim.visualModeKeyBindingsNonRecursive": [
      {
        "before": [ "\\", "b" ],
        "commands": [ "latex-workshop.wrap-env" ],
        "after": [ "<Esc>", "i"],
      }
    ],

Probably both times to execute keys are useful, so in addition to after we could have another property (afterCommands?).

Additional context
I'm worried that the commands are executed asynchronously and it's not easy to know when they're done. But hopefully that isn't the case? I could try to implement this if you agree it's useful and could give some pointers on where this happens.

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 key-binding handling for before, commands, and after, then trace whether commands such as latex-workshop.wrap-env are executed asynchronously. Done means a binding can reliably execute its simulated keys after the command completes, while preserving the existing before-command behavior.

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.