嘿,我正在寻找一种方法来使 vscode 片段将我的变量名称转换为 const case:
例如
${1:regular}
${1:/constCase/}
如果我在里面写 heyThisIsVariable ,它会变成:
heyThisIsVariable
HEY_THIS_IS_VARIABLE
最佳答案
在您的代码片段中尝试一下:
"body": [
"$1",
"${1/([a-z]+)|([A-Z][^A-Z]*)/${1:/upcase}${2:+_}${2:/upcase}/g}",
]
它适用于任意数量(1 到无穷大)的“单词”。
关于visual-studio-code - vscode 片段中的 const case,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62622190/