Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I turn on collapsible regions for markup in .cshtml (razor pages) visual studio 2012?

In visual studio 2010 markup in MVC3 and ASPX pages was collapsible (by closing tag) however it does not seem to be working in visual studio 2012. Anyone know how to get it working? I cant find it in the options...

:-)

like image 408
Exitos Avatar asked Jan 16 '13 15:01

Exitos


People also ask

How do you collapse a region in Visual Studio?

To collapse an outlining region, double-click any line in the region on the outlining margin, which appears just to the left of the code. You can see the contents of a collapsed region as a tooltip when you hover over the collapsed region.

How do I expand all regions in Visual Studio?

Expand / Close All Where you see braces or regions in code, you can collapse or expand them with the keyboard shortcut Ctrl + M, P to expand or Ctrl + M, O to collapse.

How do I add a region in Visual Studio?

Select some piece of code and use (ctrl+r, ctrl+e), type your region name and press enter. Or select some piece of code, press F1 and type "Move into #region". To remove a single #region, click the line that contains '#region' keyword and use (ctrl+r, ctrl+e).


2 Answers

Seems to work in Visual Studio 2012

 @* <!-- #region Some Name --> *@
 @* <!-- #endregion --> *@
like image 161
Leon Avatar answered Sep 26 '22 09:09

Leon


This looks like it has already been answered here: Collapse C# block within cshtml and save it However, if you're after automatic collapsing of Razor sections in your cshtml, then it looks like you're out of luck. The usual CTRL-M,M and CTRL-M+CTRL-T chorded shortcuts will work only on the html which you will see have the familiar +/- collapsing indicators on the margin.

like image 34
John Kelleher Avatar answered Sep 23 '22 09:09

John Kelleher