VSCode:将键盘命令分配给片段?

Ste*_*eve 4 visual-studio-code

在我以前使用的编辑器中,特别是 SublimeText 和 Atom,我能够创建一个简单的命令来添加一个字符,就像 我输入option-space.

例如,在 Atom 中,我在以下位置创建了命令init.coffee

atom.commands.add 'atom-text-editor',
 'editor:insert-nbsp': (event) ->
   editor = @getModel()
   editor.insertText(' ')
Run Code Online (Sandbox Code Playgroud)

然后是简单的部分,调用自定义命令的键绑定:

  'alt-enter': 'editor:insert-br'
Run Code Online (Sandbox Code Playgroud)

在 vscode 中,我知道如何执行后者(创建键绑定)但如何创建命令。

我意识到我可以创建一个片段,我已经制作了几个片段,但我想基本上 用键绑定触发片段。

我怎样才能做到这一点?

Ste*_*eve 5

自 1.9 以来,在 VSCode 中实际上要容易得多:

{
 "key": "alt+space",
 "command": "type",
 "args": {
   "text": " "
 },
 "when": "editorTextFocus"
},
Run Code Online (Sandbox Code Playgroud)