Home > Software design >  How do I find out the names of various Visual Studio Code commands when they aren't displayed i
How do I find out the names of various Visual Studio Code commands when they aren't displayed i

Time:07-20

I'm using the VSCodeVim extension and am trying to configure some shortcuts for normal mode without the need of turning the extension off then on again via its togglevim command. I'm trying to add the "View: Close Editor", "View: Open Previous Editor", and "View: Open Next Editor" commands as they're named in the keyboard shortcuts menu to the "vim.normalModeKeyBindings" setting but don't know what to put for the "commands" value.

The commands towards the bottom of the shotrcuts menu are listed in their name form while most of the commands above them have a "cleaned up" name that displays in the F1 command palette and doesn't seem to correspond to the underlying command name.

I've tried the following which results in a command not found notification:

"vim.normalModeKeyBindings": [
  {
    "before": [ "<C-w>" ],
    "commands": [
      "view.closeEditor" // I've tried all kinds of variations of capital/lowercase letters and periods/hyphens.
    ]
  },
  {
    "before": [ "<C-pageup>" ],
    "commands": [
      "view.openPreviousEditor" // See above.
    ]
  },
  {
    "before": [ "<C-pagedown>" ],
    "commands": [
      "view.openNextEditor" // See above.
    ]
  }
]

How do I find out what the underlying command name is for these "View" commands (or any such named command) so I can reference them in the settings.json?

CodePudding user response:

Even though there is only a title for some commands, like View: Close Editor you can still right-click on that command title and choose

Copy Command ID

from the context menu. That'll give you the version you need, like

workbench.action.closeActiveEditor

I don't use vim so I hope you can adapt that to use as you need.

  • Related