Skip to content

Instantly share code, notes, and snippets.

@vmishakin
Last active February 25, 2024 21:36
Show Gist options
  • Save vmishakin/db09faf9b95fcfbde6e2448e474f7031 to your computer and use it in GitHub Desktop.
Save vmishakin/db09faf9b95fcfbde6e2448e474f7031 to your computer and use it in GitHub Desktop.
VS Code snippets Variable transforms
The filename of the current document without its extensions
${TM_FILENAME_BASE}
Button.ts -> Button
The line before the first dot in the filename of the current document
Button.test.ts -> Button
${TM_FILENAME/([a-z0-9]+)\\..+$/$1/gi}
Name of the first subdirectory, after 'src' (detecting FSD layer)
${RELATIVE_FILEPATH/src\\/([a-z]+)\\/.*/$1/gi}
src/entities/Product/ui/Product/Product.ts -> entities
Name of the second subdirectory, after 'src (detecting FSD slice)
${RELATIVE_FILEPATH/src\\/[a-z]+\\/([a-z0-9]+)\\/.*/$1/gi}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment