Discovering ReSharper live templates

Let me start this off by saying - ReSharper live templates are what Visual Studio's code snippets should have been all along. Namely ReSharper's live templates allow the programmer to create powerful custom templates for multiple situations - regular, surround and file templates. It's also possible to use variables (%variable_name%) and make them either user editable or assign a macro to it. The word "macro" here is a bit deceiving. The macros used inside live templates aren't regular Visual Studio macros, rather ReSharper's own .Net macro classes implementing the JetBrains.ReSharper.Feature.Services.LiveTemplates.Macros.IMacro interface. To think about it - this allows for much greated capabilities within macros and better packaging.

One might not recognise his or her bad habbits until someone specifically points it out to them. Something like this happened to me regarding the use of a TODO snipper i've been using. The bad habbit - having to type my name and current date every time the snippet is inserted and being completely oblivious to the fact that there are better ways of doing this. As a coworker pointed out that he's using ReSharper's live templates, i started looking into them and it didn't take long to find out there were powerful ways to extend the templates. Long story short - here's my implementation of the TODO snippet - download the template XML.

This template demonstrates quite well how to use three different types of variables: ones which are user editable, ones which have a constant value assigned to them and ones which retrieve their value from a macro. To use this template save the XML above in a .xml file, open the live templates editor from the ReSharper menu and import the XML file.

P.S. - this post was written in Visual Studio 2008 on a Lenovo IdeaPad S10e running Windows 7 (all visual effects enabled) - combined memory consumption - 800 Mb. Let me end this post by saying - Windows 7 is what Vista should have been all along.

Helping a brother out,