Resharper Surround with Templates: ()

Resharper comes with live templates (ctrl + j) or surround with templates (ctrl+ alt + j) which helps with few key strokes and can save you considerable time over a period of day.

Of the available surround with templates, my most frequently used one is surrounding with curly braces, { }

image

If you use linq statements in your code, you will quickly realize how neat it would have been if there were a open and close bracket surround template, ( ).

No worries, it’s easy to create one, lets do it.

From VS.Net, go to Resharper menu and select live templates, switch to the surround templates, as shown in the following pic, notice the predefined templates.

image

Right click on User Templates, select new template.

Lets give the description and the action to perform and you are all set.

image

Lets test it.  Write your linq query, apply the shortcut ctrl + alt + j and select more options.

image

 

 

Select the open and close bracket from User Templates and mark the Add to quick list option and you will get your linq query surrounded with ( ) brackets.

Next time when you select surround with, you will get your shortcut,

image

 Write your linq, select the statement using ctrl + w (Resharper) and surround with brackets and continue the operation. 

 (from accountDetailEntity in accountDetailEntities 
     group accountDetailEntity by accountDetailEntity.AccountBalance
          into grouping
               select grouping). <--
 
Nice,  these simple shortcuts saves a good amount of time . Thanks Resharper :) 
 

18 Comments

Comments have been disabled for this content.