Similarly to some VSCode extensions, I want to create a snippet that would allow me to read the filename and transform it twice:
So if my filename is my-filename.tsx
the snippet would return MyFilename
I can do one of them at a time, with this:
{
"My Snippet": {
"prefix": "snippet",
"body": [
"${TM_FILENAME_BASE/(.)/${1:/capitalize}/}",
]
}
}
and
{
"My Snippet": {
"prefix": "snippet",
"body": [
"${TM_FILENAME_BASE/(.*)/${1:/camelcase}/}",
]
}
}
But is it possible to chain both transformations and apply them at the same time?
Try this snippet:
"My Snippet": {
"prefix": "snippet",
"body": [
"${TM_FILENAME_BASE/(.)(.*)/${1:/capitalize}${2:/camelcase}/}",
]
}
It just captures the rest of your variable and camelCases it.
But doesn't this simpler version do what you want:
"${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/}",