有没有办法在您按下某个键时查看 运行 是什么命令?
Is there a way to see what command is run when you press a key?
我想在 Visual Studio 代码中重新映射我的键,但在某些情况下无法弄清楚 运行 是什么命令。
例如,如果我在查找小部件(上下文 findInputFocussed==true)中并想转到输入文本的开头,我可以按 home,但我似乎找不到连接到 home 按钮的命令,用于将光标带到输入的开头(我已经重新映射所有链接到 home 按钮的命令)。
另一个例子是在终端中按 up 来获取上一个命令。
如何找到命令以便我可以将它们重新映射到我自己的键?
我认为标题 "is there a way to see the command" 中提出的问题的最佳答案是 否 。这被归档为 VSCode Issue #38602: Add feature to describe keybinding by pressing said key(s),被关闭为 "duplicate",但他们真正的意思是 "unnecessary".
为什么不需要?假定您可以在键绑定 UI (VSCode Issue #57935: Search in keybindings editor by pressing keyboard shortcut) 中搜索您感兴趣的键,如这些问题中所引用:
How can I find what command a keybinding is bound too easily?
How do I find out which command name is bound to a particular key sequence in VSCode and vice-versa?
但是,问题的 body 侧重于两个不属于现有问题和答案范围的示例,即行为 not 由以下因素确定的键通过 VSCode 键绑定系统。具体来说,我们有:
- 在“查找”框获得焦点时按 主页。
- 在终端window中按↑。
不仅没有 "describe key",而且据我通过实验得知,不可能将不同的键绑定到它们的功能上。例如,Home 默认绑定到 cursorHome
命令,但将其他内容绑定到 cursorHome
,例如 Ctrl+P,不会导致能够通过按该新组合转到“查找”框的开头。正如 Mark 指出的那样,这些绑定可能来自某些 lower-level 组件基础结构,并且键默认绑定到的命令不能替代它。我发现 something similar 关于 Tab 键。
因此,如果您的最终目标是能够按不同的键来完成这些事情,您可能需要向 VSCode 团队提交一个新问题。 (粗略搜索 issues 后我没有看到任何存在的东西。)
此信息大部分已经在问题的评论中,并且不一定涵盖特定功能可能来自 OS 而不是 VSCode 的情况(这可能是原始问题中 Home
键的情况)。
这就是我在 Emacs 中为我提供类似 describe-key
的东西所做的。在 keybindings.json
我有:
[
// ...snip...
// Show the keybinding GUI and "record keys" if you're already in the
// keybinding GUI
//
// To see all bindings for a key or key combination (from any ordinary
// editor), do `C-h C-k C-h C-k` then the key(s) you're interested in.
{ "key": "ctrl+h ctrl+k", "command": "workbench.action.openGlobalKeybindings", "when": "!inKeybindings" },
{ "key": "ctrl+h ctrl+k", "command": "keybindings.editor.recordSearchKeys", "when": "inKeybindings" },
// describe-key - Toggle the debug keybindings console
//
// It's noisy, but it does show you what binding is actually executed for a
// keypress in a particular context:
// https://code.visualstudio.com/docs/getstarted/keybindings#_troubleshooting-keybindings
{ "key": "ctrl+h ctrl+shift+k", "command": "workbench.action.toggleKeybindingsLog" },
// ...snip...
]
我想在 Visual Studio 代码中重新映射我的键,但在某些情况下无法弄清楚 运行 是什么命令。
例如,如果我在查找小部件(上下文 findInputFocussed==true)中并想转到输入文本的开头,我可以按 home,但我似乎找不到连接到 home 按钮的命令,用于将光标带到输入的开头(我已经重新映射所有链接到 home 按钮的命令)。 另一个例子是在终端中按 up 来获取上一个命令。
如何找到命令以便我可以将它们重新映射到我自己的键?
我认为标题 "is there a way to see the command" 中提出的问题的最佳答案是 否 。这被归档为 VSCode Issue #38602: Add feature to describe keybinding by pressing said key(s),被关闭为 "duplicate",但他们真正的意思是 "unnecessary".
为什么不需要?假定您可以在键绑定 UI (VSCode Issue #57935: Search in keybindings editor by pressing keyboard shortcut) 中搜索您感兴趣的键,如这些问题中所引用:
How can I find what command a keybinding is bound too easily?
How do I find out which command name is bound to a particular key sequence in VSCode and vice-versa?
但是,问题的 body 侧重于两个不属于现有问题和答案范围的示例,即行为 not 由以下因素确定的键通过 VSCode 键绑定系统。具体来说,我们有:
- 在“查找”框获得焦点时按 主页。
- 在终端window中按↑。
不仅没有 "describe key",而且据我通过实验得知,不可能将不同的键绑定到它们的功能上。例如,Home 默认绑定到 cursorHome
命令,但将其他内容绑定到 cursorHome
,例如 Ctrl+P,不会导致能够通过按该新组合转到“查找”框的开头。正如 Mark 指出的那样,这些绑定可能来自某些 lower-level 组件基础结构,并且键默认绑定到的命令不能替代它。我发现 something similar 关于 Tab 键。
因此,如果您的最终目标是能够按不同的键来完成这些事情,您可能需要向 VSCode 团队提交一个新问题。 (粗略搜索 issues 后我没有看到任何存在的东西。)
此信息大部分已经在问题的评论中,并且不一定涵盖特定功能可能来自 OS 而不是 VSCode 的情况(这可能是原始问题中 Home
键的情况)。
这就是我在 Emacs 中为我提供类似 describe-key
的东西所做的。在 keybindings.json
我有:
[
// ...snip...
// Show the keybinding GUI and "record keys" if you're already in the
// keybinding GUI
//
// To see all bindings for a key or key combination (from any ordinary
// editor), do `C-h C-k C-h C-k` then the key(s) you're interested in.
{ "key": "ctrl+h ctrl+k", "command": "workbench.action.openGlobalKeybindings", "when": "!inKeybindings" },
{ "key": "ctrl+h ctrl+k", "command": "keybindings.editor.recordSearchKeys", "when": "inKeybindings" },
// describe-key - Toggle the debug keybindings console
//
// It's noisy, but it does show you what binding is actually executed for a
// keypress in a particular context:
// https://code.visualstudio.com/docs/getstarted/keybindings#_troubleshooting-keybindings
{ "key": "ctrl+h ctrl+shift+k", "command": "workbench.action.toggleKeybindingsLog" },
// ...snip...
]