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

5

14

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...

:-)

Scopophilia answered 16/1, 2013 at 15:24 Comment(0)
D
32

This worked for me in Visual Studio 2013:

<!-- #region Targets -->

<h1>Targets</h1>

<fieldset>

...

</fieldset>

<!-- #endregion -->
Disfeature answered 10/3, 2015 at 21:49 Comment(2)
@MatheusMiranda Taken from a forum post "under Tools, Options, Text Editor, C#, Advanced the last option 'Collapse #regions when collapsing to definitions' is not checked. Checking it fixed this issue. It used to be the default"Conversational
Just an FYI - The simple method above works in Visual Studio 2022 as well (an MVC5 project in this case)Northeasterly
A
1

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.

Anana answered 7/5, 2013 at 8:17 Comment(0)
E
1

Seems to work in Visual Studio 2012

 @* <!-- #region Some Name --> *@
 @* <!-- #endregion --> *@
Etherify answered 26/6, 2017 at 14:50 Comment(3)
The question refers to Visual Studio 2012. See question.Etherify
Does the most-voted solution also work? If so, then it's a better solutionConversational
I no longer have VS2012 but at the time the excepted answer did not work in VS2012. Web essentials did not support that syntax until WE 2013 vswebessentials.com/features/html#region What I proposed was a work around that did work in VS2012.Etherify
M
0
  1. Highlight your code block.
  2. Right-click
  3. Select "Collapse Tag"
Malcom answered 15/7, 2013 at 15:13 Comment(1)
Can we save the collapsed region so that if we restart visual studio, it remembers where we added our own custom tags/outlines/regions? Ctrl+M+H makes a custom collapsible region of the highlighted text but does not remember it on VS restart.Stoneblind
M
0

For whatever reason

<!-- #region Targets -->
-- Code Here --
<!-- #endregion -->

did not work. It would not let collapse that region.

What did work was:

@{ #region CommentsSection }
    -- Code Here --
@{ #endregion CommentsSection }
Mihrab answered 28/6 at 2:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.