1

I use UltiSnips to manage my snippets and I have a few snippets in typescriptreact but I'm not able to use them in typescript.

Is there a way to share snippets between them?

1 Answer 1

1

There are a couple of ways to share snippets:

  1. Using a dotted filetype
  2. Using extends

For the first method, set the dotted filetype with

:set ft=typescriptreact.typescript

and you can use both typescriptreact and typescript snippets for the current buffer. (See the end of the section :h UltiSnips-how-snippets-are-loaded for details)

The second method allows the use of both snippets for all files of a certain filetype (not just for a certain buffer). To use typescriptreact snippets in a typescript file, add the line

extends typescriptreact

to the typescript snippets file. Now, when UltiSnips activates snippets for a typescript file, it looks for all typescripteact snippets and activates them as well. (See the top of :h UltiSnips-basic-syntax for details)

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.