2

I read the document and it seems that regex expression is only used in snippet body.

Mark
  • 143,421
  • 24
  • 428
  • 436
kakakali
  • 159
  • 1
  • 11

1 Answers1

2

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".

Mark
  • 143,421
  • 24
  • 428
  • 436