开发者

Outlining IF-ELSE code block in Visual Studio 2010

Wondering if there is anyway way to expand开发者_开发知识库/collapse the IF-ELSE code block in VS2010? Sometimes the code inside IF-ELSE is too long and I would like to hide it.

Anyway one know? Thanks a lot!

EDIT: Please be informed that I'm using #region & #endregion inside the IF-ELSE statement. Try looking for more convenient style like JScript extension does.


Go to the Options dialog box and select Text Editor, expand C/C++, and then click Formatting. Activate "Automatic outlining of statement blocks."

Source: http://msdn.microsoft.com/en-us/library/0x6hx0kx.aspx

I'm using the full version of Visual Studio 2010, don't know if this is available in the express version.


you can add regions, regions are collapsable

#region Name
if()
{
    ///code
}
endregion


Try surrounding the if-else with a region:

#region regionName
if()
{
   #region regionName
   #endregion
}
else
{
}
#endregion

You can also select the block you want to hide and press Ctrl+M,Ctrl+H

or

Select the block -> right click it -> Outlining -> Hide Selection

So

You will have a '+' on the left to hide and show it when you want.


Go to Tools -> Options -> Text Editor -> C# -> Formatting -> Indentation. Tick "Indent open and close brackets".

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜