2

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

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.