dthrasher
dthrasher

Reputation: 41802

Create ReSharper live template for comments

I'd like to create a ReSharper template that can only be used within comments in my code, but I'm not sure how to do that.

The template I'm creating is a simple one. It allows me to insert the name of the current user and today's date. This is very useful for putting a signature on comments (especially todos).

The live template looks like this:

$name$ $date$

The template works fine, but ReSharper allows me to use it anywhere within my code file. Ideally, I'd like to use it only within a comment block.

I see that ReSharper has options to limit the use of a template to where namespace declarations, type member declarations, query statements, etc. are allowed. Does it have the ability to limit the use of a template to within a comment block? If so, how do I do it?

(Note: I'm using ReSharper 6.1)

Upvotes: 0

Views: 526

Answers (1)

Dmitri Nesteruk
Dmitri Nesteruk

Reputation: 23789

Unfortunately there is currently no way to constrain a template to comments by using the 'Select scopes' functionality provided in ReSharper. It is, however, entirely possible to introduce such a constraint to the 'Select scopes' window, but that would require writing a small plug-in using the R# SDK. If this is something you'd be interested in doing, I can elaborate further with details.

Upvotes: 2

Related Questions