Andrew Connell

VS.NET Tip: Collapsing Lines in an ASPX or HTML File

I just HAD to pass this along. Just today I was bitching about not being able to hide long ASP code in a legacy project I'm maintaining. One of the things I love about the C# editor in VS.NET is how it lets you collapse regions into a little plus sign. Then when I want it back I can just click to plus to see what's there. I'm currently working on a Windows SharePoint Services (WSS) Site Definition and I'm using VS.NET to edit the template ASPX files. What I really wanted was a way to collapse table and div tags down into plus signs so I could get the out of my way. Well, it turns out you can do it! Here's how: Select the text you want to collapse, and choose Outlining | Hide Selection from the Edit menu (or just use CTRL-M, CTRL-H). POW! The file now has a collapsed region. You can open and close that region by clicking the plug sign or using CTRL-M, CTRL-M. Very cool. BTW... so far this works in any text file you open in VS.NET. We'll see if that keeps up. Related... [Geek Noise]...

I just HAD to pass this along. Just today I was bitching about not being able to hide long ASP code in a legacy project I’m maintaining.

One of the things I love about the C# editor in VS.NET is how it lets you collapse regions into a little plus sign. Then when I want it back I can just click to plus to see what’s there.

I’m currently working on a Windows SharePoint Services (WSS) Site Definition and I’m using VS.NET to edit the template ASPX files. What I really wanted was a way to collapse table and div tags down into plus signs so I could get the out of my way.

Well, it turns out you can do it!

Here’s how:

Select the text you want to collapse, and choose Outlining | Hide Selection from the Edit menu (or just use CTRL+ M , CTRL+ H ).

POW! The file now has a collapsed region. You can open and close that region by clicking the plug sign or using CTRL+ M , CTRL+ M .

Very cool.

BTW… so far this works in any text file you open in VS.NET. We’ll see if that keeps up.

Related…

[ Geek Noise ]

Andrew Connell
Developer & Chief Course Artisan, Voitanos LLC. | Microsoft MVP
Written by Andrew Connell

Andrew Connell is a web developer with a focus on Microsoft Azure & Microsoft 365. He’s received Microsoft’s MVP award every year since 2005 and has helped thousands of developers through the various courses he’s authored & taught. Andrew’s the founder of Voitanos and is dedicated to delivering industry-leading on-demand video training to professional developers. He lives with his wife & two kids in Florida.