VS Code: How to convert snippet placeholder to uppercase or lowercase?
·
Answer a question
In VS Code, the docs for creating user defined snippets mentions some Grammar which includes options for /upcase
, /downcase
, and /capitalize
, but I can't figure out how to use it.
I'm using the latest version of VS Code: Version 1.25.0
on Mac.
It seems like this snippet should convert the value of the placeholder to uppercase and to lowercase after typing it and hitting tab, but it doesn’t:
"test": {
"prefix": "test",
"body": "${1} -> ${1:/upcase} ${1:/downcase}"
},
Flow and Expected Result
-
type
test
-
hit tab to get the snippet.
-
type
Asdf
to result in:Asdf -> Asdf Asdf
-
hit tab to get expected result of:
Asdf -> ASDF asdf
Current Result
asdf -> asdf asdf
Answers
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)