假设我有一个Ruby
用户代码段输出字符串ruby和一个Python
用户代码段输出字符串python。如何在ruby模式下使Ctrl+b调用上述Ruby
代码段,而Python
在python模式下如何调用代码段?
{
"key": "ctrl+b",
"command": "editor.action.insertSnippet",
"args": {
"snippet": "ruby"
},
"when": "editorLangId == ruby"
},
{
"key": "ctrl+b",
"command": "editor.action.insertSnippet",
"args": {
"snippet": "python"
},
"when": "editorLangId == python"
},
另外,您可以使用langId
和name
参数,而不是使用snippet参数值来定义内联代码段,而是引用现有的代码段。
https://code.visualstudio.com/docs/getstarted/keybindings#_when-clause-contexts
https://code.visualstudio.com/docs/languages/identifiers#_known-language-identifiers
https://code.visualstudio.com/docs/editor/userdefinedsnippets#_assign-keybindings-to-snippets
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句