visual-studio-codevscode-snippets

How to remove the file extension using a snippet variable. List of snippet variables


I use vscode.

I want to use costum snippets, but {TM_FILENAME} has an extension name.

How can I delete the extension from {TM_FILENAME}?

like this:`

In file MyModule.js:

Transform: ${TM_FILENAME/(\w+)\.js/\1/g}

Output:

MyModule


Solution

  • You can't do this at the moment but there's a feature request on the vscode GitHub page for what you want: https://github.com/Microsoft/vscode/issues/6920.

    [EDIT]

    My answer above is now out of date - you can use the ${TM_FILENAME_BASE} variable as mentioned by other contributors.