Visual Studio Code 是否有键绑定解析器? [英] Does Visual Studio Code have a key binding resolver?
问题描述
Atom 编辑器有一个绑定到ctrl-"的命令.这称为键绑定解析器:
一旦您激活键解析器模式,您随后按下的任何键都会告诉您在所有可能的上下文中绑定了哪些命令,并显示哪些命令/上下文胜出".然后按 ctrl-g 关闭模式.
当您想知道一个键绑定是否免费,或者一个键绑定是否没有按照您的预期运行时,这很有用.
这是我在编辑器上下文中按 ctrl-n 时的示例输出,我可以看到 emacs 键绑定下一行"优先:
Emacs 也有类似的功能,它的 ctrl-h k(帮助键)命令.
是的,我通常可以通过浏览默认键盘快捷键和keybindings.json来收集我需要的信息,但是如果绑定了一个键,这可能很难做到在很多不同的情况下.
VSCode 中是否有类似的功能?
很遗憾没有,据我所知目前无法使用扩展 API 来完成.可以找到此功能的功能请求
从开发速度来看,这可能是可行的扩展或在未来几个月内包含在 vscode 中.
The Atom editor has a command that is bound to 'ctrl-.' that is called the keybinding resolver:
Once you activate key-resolver mode, any key you subsequently press will tell you what command(s) are bound to it, in all possible contexts, and show you which command/context "wins out". You then toggle the mode off by pressing ctrl-g.
This is useful for when you want to know if a key binding is free, or if a key key binding isn't doing what you expect.
Here's an example output for when I press ctrl-n in an editor context , where I can see that the emacs keybinding 'next-line' is taking precedence:
Emacs also has a similar feature with it's ctrl-h k (help keys) command.
Yes, I can usually glean the information I need by browsing the Default Keyboard Shortcuts and keybindings.json, but this can be hard to do if a key is bound in a lot of different contexts.
Is there a feature similar to this in VSCode?
Unfortunately not and as far as I know it currently can't be done using extensions API. The feature request for this feature can be found here.
Visual Studio Code evaluates keybindings as follows:
- the rules are evaluated from bottom to top.
- the first rule that matches, both the key and in terms of when, is accepted.
- no more rules are processed.
- if a rule is found and has a command set, the command is executed.
The additional User/keybindings.json
rules are appended at runtime to the bottom of the default rules, thus allowing them to overwrite the default rules.
For now you can check what is bound to a specific key using Quick Outline Preferences: Open Keyboard Shortcuts. To open this view, press ⇧+⌘+P on Mac or Ctrl+Shift+P on Windows & Linux, and look for this option.
Looking at the development pace this might be doable as extension or included in vscode in upcoming months.
这篇关于Visual Studio Code 是否有键绑定解析器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!