Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Expand/contract loops and if/then statements in VS2010?

This is annoying problem I'm having in VS2010, is there anyway I can expand and contract conditional statements and loops, as if they were methods? I realize the answer might be that I should be refactoring them out into methods if I get to this point, but humor me anyway. I thought I was once able to do this.

Edit, an example:

public void DoSomething() 
{
  if (1 < 2) {
  // long statement here
  }
}

In the left gutter of VS2010, I can contract "DoSomething" ... I cannot, however, contract the if/then statement.

like image 657
chum of chance Avatar asked Mar 30 '11 15:03

chum of chance


3 Answers

http://social.msdn.microsoft.com/Forums/en-US/vssetup/thread/73948b75-2db6-4662-80fa-5f2ace372a3b/

You can go to Tools menu -> Options. Then go to Text Editor -> C/C++ -> Formatting. Turn the Outline Statement Blocks to true.

like image 110
jbierling Avatar answered Oct 30 '22 19:10

jbierling


There's a VS 2010 plugin that does just that: http://visualstudiogallery.msdn.microsoft.com/4d7e74d7-3d71-4ee5-9ac8-04b76e411ea8

like image 31
Marek Karbarz Avatar answered Oct 30 '22 20:10

Marek Karbarz


Not automatically, as with a method, but select some lines and choose Edit, Outlining, Hide Selection. You can then expand/collapse at will. Stop Hiding will take away the +/- symbol.

like image 28
Kate Gregory Avatar answered Oct 30 '22 19:10

Kate Gregory