开发者

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 contr开发者_开发知识库act 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.


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.


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


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.


If you're working with C# you could use #region / #endregion. I'm not sure if these tags are supported in other languages or not.


I don't believe this is supported by VS2010. Could you possibly have been using something like Resharper before? I use both "vanilla" VS and VS Power Tools, and I don't have this.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜