How to find command by pressing keybinding in VSCode

前提是你 提交于 2020-01-13 08:06:50

问题


I'm looking for a way for vscode to tell me the command name for a keybinding. For example, cmd+a maps to editor.action.selectAll, so ideally I'd press a keyboard shortcut, then cmd+a, then VSCode could tell me editor.action.selectAll.

As a partial solution, I can open my keybindings.json and search for cmd+a, but this doesn't work for extensions - my particular use case is figuring out what the vim o command is called so I can remap it.

In the Emacs world, this functionality is available under describe-key (C-h k).


回答1:


You can find the command associated with a key binding by typing the keybinding into the Keyboard Shortcuts search box:

Unfortunately, per the source code, the vim extension doesn't use this mechanism to bind the o key.

Fortunately, it does let you rebind the keys in settings. First, open settings (F1 Preferences: Open Settings), then add (to bind i, for example):

"vim.normalModeKeyBindingsNonRecursive": [
    "before": ["i"],
    "after": ["o"]
],

If you have the new settings UI, you might need to search for vim.normalModeKeyBindingsNonRecursive first, and then click Edit in settings.json.




回答2:


As of the September 2018 release, VSCode can do this from the keyboard shortcuts window.

From the keyboard shortcuts window (cmd+k cmd+s), type cmd+option+k or click the keyboard icon on the right.

Kudos to this comment linking to this approach as an answer to another question.



来源:https://stackoverflow.com/questions/52303216/how-to-find-command-by-pressing-keybinding-in-vscode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!