VS Code:如何将代码片段占位符转换为大写或小写?

2024-01-05

在 VS Code 中,用于创建的文档用户定义的片段 https://code.visualstudio.com/docs/editor/userdefinedsnippets提到一些Grammar https://code.visualstudio.com/docs/editor/userdefinedsnippets#_grammar其中包括以下选项/upcase, /downcase, and /capitalize,但我不知道如何使用它。

我正在使用最新版本的 VS Code:Version 1.25.0 on Mac.

看起来这个代码片段应该在输入并点击 Tab 后将占位符的值转换为大写和小写,但事实并非如此:

"test": {
    "prefix": "test",
    "body": "${1} -> ${1:/upcase} ${1:/downcase}"
},

流程和预期结果

  1. type test
  2. hit tab to get the snippet.
  3. type Asdf以导致:

    Asdf -> Asdf Asdf
    
  4. hit tab to get expected result of:

    Asdf -> ASDF asdf
    

当前结果

asdf -> asdf asdf

尝试这个:

"test": {
    "prefix": "test",
    // "body": "${1} -> ${1/(.*)/${1:/upcase}/} > ${1/(.*)/${1:/downcase}/}"
    // simpler version below works too
    "body": "${1} -> ${1/(.*)/${1:/upcase} ${1:/downcase}/}"
}

你需要击中Tab应用转换。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

VS Code:如何将代码片段占位符转换为大写或小写? 的相关文章

随机推荐