VS Code: How to convert snippet placeholder to uppercase or lowercase?

后端 未结 3 1300
囚心锁ツ
囚心锁ツ 2021-02-01 20:54

In VS Code, the docs for creating user defined snippets mentions some Grammar which includes options for /upcase, /downcase, and /capitalize

相关标签:
3条回答
  • 2021-02-01 21:02

    For reference:

    The integer in the EBNF docs refers to a RegExp group not to a tabstop reference so should work:

    "test": {
        "prefix": "test",
        "body": "${1} -> ${1/(Asdf)/${1:/upcase}/} ${1/(Asdf)/${1:/downcase}/}"
    }
    
    0 讨论(0)
  • 2021-02-01 21:05

    See the variable transforms section of the snippets section of the manual.

    0 讨论(0)
  • 2021-02-01 21:06

    Try this:

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

    You need to hit Tab to apply the transformation.

    0 讨论(0)
提交回复
热议问题