在Visual Studio代码中,如何在组合[alt + ctrl + ']键[']中键绑定?



在visual studio代码中

如何在alt+ctrl+

'我正在搜索要放入keybindings.json中的特定命令

{
"key": "alt+ctrl+'",
"command": "????????????command?????????????",
"when": "editorTextFocus && !editorReadonly"
}

我想您希望Ctrl+Alt+'

{
"key": "ctrl+alt+'",
// "command": "type",       // normally this would work
// "args": {"text":"`"},
// "command":  "editor.action.insertSnippet",  // this outs just one backtick
// "args": {
//   "snippet": "`"
// },
"command":  "editor.action.insertSnippet",
"args": {
"snippet": "`$TM_SELECTED_TEXT`"   // use this to wrap selected text with backticks
},
"when": "editorTextFocus && !editorReadonly"
},

通常情况下,type命令是您在这里使用的,但由于它输出一个backtick,vscode会自动添加另一个-就像键入一个">输出两个一样。除非您将Editor > Auto Closing Quotes设置为never,否则这将影响所有引号,而不仅仅是backtick。

因此,如果您只想要一个backtick,请使用insertSnippet命令版本——它只输出一个backstick。

最新更新