0

在视觉工作室代码中

如何在组合 alt++中进行键ctrl绑定' 以输出反引号`作为引号?

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

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

1 回答 1

1

我假设您希望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命令是您将在此处使用的命令,但由于它输出反引号,vscode 会自动添加另一个 - 就像键入一个"输出两个一样。除非您将Editor > Auto Closing Quotes设置设置为never,但这会影响所有引号,而不仅仅是反引号。

因此,如果您只想要一个反引号,请使用insertSnippet命令版本 - 它只输出一个反引号。

于 2020-03-16T22:33:23.323 回答