vscode 中自定义片段的键绑定?

Key binding of custom snippet in vscode?

VS 代码:1.28.1

Mac OS 高山脉 10.13.6

我创建了一个自定义代码段以在 HTML 文件中添加插值。它在使用 F1 >insert snippet 方式时工作正常但我需要添加键绑定以便它可以与键盘一起使用。这是我所做的,但它不起作用。

vs code tutorial

的帮助下创建一个片段
{
  "interpolate": {
    "prefix": "inter",
    "body": ["{{ ${CLIPBOARD} |json }}"],
    "description": "Interpolate this"
  }
}

现在我需要绑定快捷键并将其添加到keybindings.json

{
    "key": "shift+cmd+i",
    "command": "editor.action.interpolate",
    "when": "editorTextFocus",
    "args": {
      "langId": "html",
      "name": "interpolate"
    }
  }

但是每当我点击 Cmd+Shift+I。抛出错误

"command 'editor.action.interpolate' not found

我这里做错了什么?

找到解决方案,我们需要在keybindings.json中添加name的值,与user snippet的key相同文件 html.json

html.json

{
  "interpolate": { // this is the name of snippet
    "prefix": "inter",
    "body": ["{{ ${CLIPBOARD} |json }}"],
    "description": "Interpolate this"
  }
}

keybindings.json

{
    "key": "shift+cmd+I",
    "command": "editor.action.insertSnippet",
    "when": "editorTextFocus",
    "args": {
      "langId": "html",
      "name": "interpolate" << same as name of snippet
    }
  }