Ben Wong
Ben Wong

Reputation: 399

VSCode Snippet Help/Chaining transform

I thought I was getting the hang of making my own snippets, but I can't figure out to transform a tab stop so that 'Ignore/Before/Slashes/Oh Hey Text' becomes 'OhHeyText'.

so far I have this

${4/.*\\/(.+$)/$1/g}

or

${4/\\s//g}

But I can't figure out how to chain the transforms together. I've read through 5 or 6 posts here on SO already, but I'm having a lot of trouble grokking the actual transformation syntax, and extrapolating that to my use case.

Thanks for any help you can give!

Upvotes: 2

Views: 160

Answers (1)

Wiktor Stribiżew
Wiktor Stribiżew

Reputation: 627103

You can use

"${TM_DIRECTORY/^.*[\\/\\\\]|\\s+//g}"

See the regex demo. Details:

  • ^.*[\/\\] - start of string, any zero or more chars other than line break chars as many as possible, and then / or \
  • | - or
  • \s+ - one or more whitespaces.

Upvotes: 2

Related Questions