gpt4 book ai didi

visual-studio-code - 如何在 Visual Studio Code 中自定义上下文菜单?

转载 作者:行者123 更新时间:2023-12-04 04:36:57 25 4
gpt4 key购买 nike

是否可以在 Visual Studio Code 中自定义上下文菜单?

目前它看起来像这样。

enter image description here

我需要为此添加另外两个菜单选项。

像“回去”和“前进”之类的东西。

这能做到吗?

最佳答案

是的,您可以通过创建供您自己使用的个人扩展将菜单项添加到上下文菜单中。在您的分机中,在 package.json , 添加 contributes.menus 部分。文本编辑器上下文菜单名为 editor/context .
(如果您之前没有开发过扩展,请从 Microsoft 的 Your First Extension 教程开始。)
查看另一个将项目添加到上下文菜单的扩展可能会有所帮助。执行此操作的(众多)扩展之一是 Bookmarks ,它添加了三个上下文菜单条目。其相关部分 package.json 是:

{
"name": "Bookmarks",
...
"contributes": {
...
"menus": {
...
"editor/context": [
{
"command": "bookmarks.toggle",
"group": "bookmarks",
"when": "editorTextFocus && config.bookmarks.showCommandsInContextMenu"
},
{
"command": "bookmarks.jumpToNext",
"group": "bookmarks@1",
"when": "editorTextFocus && config.bookmarks.showCommandsInContextMenu"
},
{
"command": "bookmarks.jumpToPrevious",
"group": "bookmarks@1",
"when": "editorTextFocus && config.bookmarks.showCommandsInContextMenu"
}
],
....
},
....
},
....
}
command可以是任何命令;它不必是由您的扩展程序安装的。
API docsgroup 的含义有点含糊属性:

Last, a group property defines sorting and grouping of menu items.


它的含义在 Sorting of groups 下有更完整的描述。 .像“bookmarks”这样的词建立一组菜单条目,通过水平规则与其他组分开,组按字母顺序排列,“@ ”后缀控制每个组内的排序:
Screenshot of three added context menu items

关于visual-studio-code - 如何在 Visual Studio Code 中自定义上下文菜单?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46714353/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com