views:

221

answers:

1

Is there and easy way to remove the IF/End If structured pairing. Being able to do this in one keystroke would be nice (I also use Refactor! Pro)

Right now this is what I do:

  1. Delete the IF line
  2. Watch Visual Studio reformat the code to line up correctly taking into account that the IF is Missing.
  3. Navigate to the End If
  4. Delete the End If line

i.e. In the following example I want to change the code from

IF Value = True Then
  DoSomething()
  DoSomething2()
End IF

To

DoSomething()
DoSomething2()
+1  A: 

While this is not a literal refactoring in the sense specified by Martin Fowler's book Refactoring, This is how I use resharper to achieve this goal:

  1. Move/click on like with if statement
  2. Press control + delete to delete the line
  3. Press Alt + enter, and the option remove braces will be the first one specified.
  4. Press enter

Done. Not quite simple, but the keystrokes are short, and not too complicated, and I don't have to spend/waste time with dumb arrow keys or the mouse to accomplish this type of code change.

Resharper supports VB.net code as of 4.0, I believe.

casademora
Thanks for your answer. I am going to have to see if Refactor! Pro has a similar feature. I also edited the question and removed references to Refactor.
Gerhard Weiss