Visual Studio Code 为右键单击菜单按钮创建按键绑定

发布于 2025-01-11 00:11:13 字数 138 浏览 0 评论 0原文

例如,在 VS Code 中,我可以右键单击变量,选择 Peek >查看类型定义。

我怎样才能为此创建一个键绑定(目前没有键绑定集)?如果“查看类型定义”按钮未映射到任何内容,我怎样才能找到 keybindings.json 文件的适当命令?

For example, in VS Code, I can right click on a variable, select Peek > Peek Type Definition.

How can I make a keybinding for this (currently there is no keybinding set)? How can I even find the appropriate command for the keybindings.json file, if the "Peek Type Definition" button is not mapped to anything?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

为你鎻心 2025-01-18 00:11:13

转到右下角的齿轮图标。单击它并选择键盘快捷键。它将打开键盘快捷键编辑器。

在该编辑器顶部的输入框中,输入 peek type,您将看到显示 2 个条目。一是:

查看类型定义
editor.action.peekTypeDefinition

该命令没有默认快捷方式,但您可以自己创建一个。

如果将鼠标悬停在该条目上,其左侧将出现一个 + 符号,单击它,将打开一个输入对话框,您可以在其中输入您选择的键绑定。

它将在您的 keybindings.json 中创建一个键绑定,例如

{
  "key": "alt+5",                 // whatever you chose here
  "command": "editor.action.peekTypeDefinition"
}

Go to the Gear Icon in the lower right. click it and select Keyboard Shortcuts. It will open the Keyboard Shortcuts editor.

In that editor's input box at the top, type peek type and you will get 2 entries shown. One is:

Peek Type Definition
editor.action.peekTypeDefinition

That command does not have a default shortcut, but you can make one yourself.

If you hover over that entry, a + sign will appear to its left, click it and an input dialog opens where you can enter your chosen keybinding.

It will make a keybinding in your keybindings.json like

{
  "key": "alt+5",                 // whatever you chose here
  "command": "editor.action.peekTypeDefinition"
}
终难遇 2025-01-18 00:11:13

当您右键单击时,弹出的窗口称为上下文菜单。有些键盘有上下文菜单按钮。不幸的是,VSCode 不使用此命令作为键盘快捷键中的命令,因此无法通过键盘快捷键菜单来执行此操作。

或者,您可以使用 SharpKeys,这是一个可以让您重新映射按键的实用程序在你的键盘上。就我个人而言,我将右侧 Alt 键映射到上下文菜单按钮。在 SharpKeys 中,上下文菜单按钮没有名称,因此仅称为特殊:应用程序 (E0_5D)。这允许您从键盘上右键单击。

在下面的屏幕截图中,您可以在突出显示的部分中看到重新映射。
输入图片此处描述

When you right click, the window that pops up is called the context menu. Some keyboards have a context menu button. Unfortunately, VSCode does not use this as the command in the keyboard shortcuts, so there is no way to do this through the keyboard shortcuts menu.

Alternatively, you could use SharpKeys, a utility that lets you remap keys on your keyboard. Personally, I have my right alt key mapped to the context menu button. In SharpKeys, the context menu button does not have a name, so it is just called Special: Application (E0_5D). This allows you to right click from the keyboard.

In the screenshot below, you can see the remap in the highlighted section.
enter image description here

起风了 2025-01-18 00:11:13

相当于用鼠标右键单击编辑器面板中的符号,有一个键盘快捷键

“在 textInputfocus 上显示编辑器上下文菜单”。

默认绑定是 [shift]+f10。

这将打开右键菜单,您可以使用箭头导航到菜单项。
强文本
输入图片此处描述

The equivalent of right-clicking with a mouse a symbol in an editor panel has a keyboard shortcut

'Show Editor Context Menu on textInputfocus'

The default binding is [shift]+f10.

This will open the right-click menu, and you can navigate with arrows to your menu item.
strong text
enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文