作者:WE艺家人-千乐 | 来源:互联网 | 2023-02-12 11:50
我正在使用VSCode编写Swagger(OpenAPI)规范,我想利用特定的扩展来帮助编写该规范.
我安装的扩展程序没有为我提供密钥绑定,可以轻松调用它.
如何添加密钥绑定?我试图通过单击文件 - >首选项 - >键盘快捷键并编辑keybindings.json文件来使其工作,但到目前为止没有成功.
我似乎必须发现扩展程序的命令,我不知道在哪里找到它,在我点击扩展集线器时,在扩展摘要页面上似乎不是很明显,然后在我要使用的扩展名上.
1> Get Off My L..:
如果您打开扩展程序的信息窗口,您可能会看到一个Contributions
选项卡,在那里您可能会看到一个Commands
列表.
从那里你可以找到你想要的命令并在你的keybindings.json
文件中绑定它File -> Preferences -> Keyboard Shortcuts
[
{
"key": "ctrl+enter",
"command": "command.execute",
"when": "editorTextFocus"
}
]
2> Tore Aurstad..:
如果有人为VSCode编写了自己的扩展名,则可以使用keybindings属性以及内部的props属性来为命令设置默认的键绑定。由Yeoman yo code命令初始化的示例项目的package.json中的示例设置:
{
"name": "static-site-hero",
"displayName": "Static site hero",
"description": "Helps with writing posts for static site generator",
"version": "0.0.1",
"engines": {
"vscode": "^1.30.0"
},
"categories": [
"Other"
],
"activationEvents": [
"onCommand:extension.helloWorld",
"onCommand:extension.insertLink",
"onCommand:extension.insertFigure"
],
"main": "./extension.js",
"contributes": {
"commands": [
{
"command": "extension.helloWorld",
"title": "Hello World"
},
{
"command": "extension.insertLink",
"title": "Insert Markdown Link to File or Image"
},
{
"command": "extension.insertFigure",
"title": "Insert HTML figure"
}
],
"keybindings": [
{
"command": "extension.insertLink",
"key": "ctrl+alt+l",
"mac": "shift+cmd+f",
"when": "editorTextFocus"
},
{
"command": "extension.insertFigure",
"key": "ctrl+alt+F",
"mac": "shift+cmd+l",
"when": "editorTextFocus"
}
]
},
"scripts": {
"postinstall": "node ./node_modules/vscode/bin/install",
"test": "node ./node_modules/vscode/bin/test"
},
"devDependencies": {
"typescript": "^3.1.4",
"vscode": "^1.1.25",
"eslint": "^4.11.0",
"@types/node": "^8.10.25",
"@types/mocha": "^2.2.42"
}
}