How to: Enable outlining (collapsible statement blocks) for C# code in Visual Studio

I’m often modifying existing C# code in Visual Studio and find myself trying to line up opening and closing braces and trying to figure out what level of nesting I’m currently at. It’s easy when the block fits on a single screen without scrolling, but dive into some complex logic where you’ve got plenty of nested if, else, switch, try, catch blocks it’s easy to get disoriented scrolling up and down trying to figure out the logic.

Yes I can hear the code purists begging me to restructure the code and encapsulate logic away into smaller more focused methods. I don’t disagree, it fact that might be the reason I’m looking at the code in the first place, but I need to understand the logic before I start pulling it apart.

Whatever the reason I’m sure you’ve all been in the situation, why can’t I just collapse this  switch block, or if block? Wouldn’t that make things simple? Luckily the solution to this problem is simple – there’s a free Visual Studio Extension called C# Outline and it’s available for Visual Studio 2010, 2012, 2013 & 2015.

This nifty extension provides outlining (expand/collapse) for all block elements that use curly braces { }; Just like you get out-of-the-box for classes and methods It’s simple and a massive time saver.


About Cameron Dwyer

Architect and developer at OnePlace Solutions. Passionate about delivering compelling solutions on the Office 365/SharePoint platform. Addicted to coffee.

Posted on January 29, 2015, in C# and tagged , , , , , , . Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: