Difference between Live Template and Visual Studio Snippet?

Hi all:

So, I see a lot of information about Live Templates, but I'm having trouble getting my head around what they give me vs built-in Visual Studio Snippets.  So, if I can write a snippet that can work with just Visual Studio, what criteria would I use to decide to build it as a Live Template instead?

1 comment
Comment actions Permalink

Live Templates are very similar to Visual Studio's snippets, but have more power, based on the use of macros. Visual Studio snippets have some functions that can be called to replace e.g. class name and namespace, but ReSharper has way more - here's the list of all available template macros. Also, live templates can be used to create files, and can be used to create multiple files at once - see the docs on multi-file templates. Another nice feature of live templates is that ReSharper can and will reformat the code once it's been inserted, and will shorten references - where the template has the fully qualified name of a type, ReSharper will replace that with the short name, and automatically add a using statement to the top of the file. Finally, ReSharper doesn't show Visual Studio's snippets in its code completion, only showing live templates. You can still insert snippets by typing the shortcut and hitting tab, but it doesn't appear in the code completion list (partly because VS has its own insertion UI, and allows for templates with a long name rather than a shortcut).

0

Please sign in to leave a comment.