ReSharper 2016.1 Help

Quickly introduce using statements and try...catch blocks

Apart from being able to generate blocks of code with live templates, ReSharper also lets you surround existing code with additional statements, such as try...catch or using statements.

To show the surround menu, simply select the block of code and press Ctrl+Alt+J. This will pop up a menu of available surround statements:

'Surround With' pop-up

Now, you can simply press one of the shortcut keys on the right to surround the code. For example, to surround the code with a try...catch, you can press 8 on your keyboard. ReSharper will generate the default code stub and allow you to configure any optional values:

Specifying parameters of a surround template

In the Surround menu, you can also press More... in order to see a total list of available surround templates and pick which ones are added to the quicklist (the list you get when you fire up the command):

'Choose Template' dialog box helps selecting file and surround templates

See Also

Last modified: 19 August 2016