【发布时间】:2020-12-21 15:33:44
【问题描述】:
我想使用 sn-p 来转换 '.'到 '_'。我想把这个sn-p绑定到一个快捷键上。
我将以下内容添加到keybindings.json 文件中。
//keybindings.json
//Snippet-1
{
"key": "alt+u",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus",
"args": {
"snippet": "${1/[.]/_/g}",
},
},
按alt+u 不会插入sn-p。
但是以下工作:
//keybindings.json
// Snippet-2
{
"key": "alt+u",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus",
"args": {
"snippet": "${1/[.]/_/g}_more_text",
},
},
当 sn-p 中有一些文本时它可以工作,但当 sn-p 中没有文本时会失败。
任何帮助将不胜感激。
编辑 2020/09/03:
这个 sn-p 在全局 sn-p 文件中工作(如下所示)。仅当我在键绑定中使用它时才会失败。
//Snippet-3
"snake_case": {
"prefix": "sn",
"body":"${1/[.]/_/g}"
},
【问题讨论】:
-
这应该可以工作(你可以在它后面放一个空格并且它可以工作),所以它看起来像一个错误。您要在其中粘贴一些文本进行转换吗?
标签: visual-studio-code vscode-settings code-snippets vscode-snippets