Reputation: 187
I read the document and it seems that regex expression is only used in snippet body.
Upvotes: 2
Views: 1919
Reputation: 180885
Regex's can only be used to transform snippet variables in the body of the snippet, but you can put multiple snippet prefixes like this:
"stripLastDirectory": {
"prefix": ["lsd", "lsf", "lsq"],
"body": [
"${TM_DIRECTORY/.*[\\\\|\\/]+(.*)/$1/}"
],
},
So perhaps you can accomplish what you need that way.
Another alternative with some pluses (can use javascript within the snippet!) and minuses (no support for vscode variables like ${file}
) is the extension HyperSnips which does allow you to use pure regex for snippet "prefixes".
Upvotes: 2