VSCode相同的代码片段,带有不同的占位符

问题描述 投票:0回答:1
"test": {
        "prefix": "test",
        "body": "${1:hello} ${1:world}"
    }

预期结果:

hello world

当前结果:

hello hello

我正在尝试创建具有相同索引和不同占位符的代码段,但是当代码段调用时,第二个占位符更改为第一个。

案例情况:

如果删除hello,则也应删除world;如果不更改默认值hello,则制表符应转到下一个world。然后,如果我更改world,则hello不应该受到影响。

此功能与Atom兼容,但不适用于vscode!

visual-studio-code atom-editor placeholder code-snippets textmate
1个回答
0
投票

老实说,我很惊讶Visual Studio Code中的这种方法可以工作,因为我认为它不应该。无论如何,您需要更改第二个占位符的索引才能使索引起作用:

"test": {
    "prefix": "test",
    "body": "${1:hello} ${2:world}"
}
© www.soinside.com 2019 - 2024. All rights reserved.