Comment Opening and Closing Brackets (with ReSharper?)

375 Views Asked by At

Does anyone know if there's a way in Visual Studio 2010 with ReSharper 6.1 to comment out the selected lines of code with their closing brackets - or simply to comment out both the highlighted opening bracket and it's corresponding closing bracket? Here's an example of what I mean:

if(something) {
  do(this);
}

I am looking for a hot-key so that when if(something) { is selected, it will comment out if(something) { and }, preferably fixing the tabs once commented like so:

// if(something) {
do(this);
//}
1

There are 1 best solutions below

1
On BEST ANSWER

This isn't entirely what you're after, but it's pretty close:

Highlight the code inside the if statement by placing the cursor at one brace and hitting Ctrl + Shift + ].

Now hit Ctrl + Shift + Alt + Left Arrow. This will move the code 'left', i.e. outside of the if statement.

You don't need to comment the if statement out after this because it's empty.

Note that you can also move code 'right' to put it back in the if statement later.