Anyone know how to turn off code folding in visual studio 2008? Some of my colleagues love it, but I personally always want to see all the code, and never want code folded out of sight. I'd like a setting that means my copy of Visual Studio never folds #regions
or function bodies.

- 20,542
- 15
- 71
- 88
9 Answers
Edit: I recommend this other answer
Go to the Tools->Options menu. Go to Text Editor->C#->Advanced. Uncheck "Enter outlining mode when files open".
That will disable all outlining, including regions, for all c# code files.
-
11Unchecking this option disables outlining completely however. Is there another setting somewhere that will just display all regions in the code expanded when a file is opened? – Dirk Vollmar Oct 13 '09 at 08:50
-
I think you have to use Macros to do that, but I don't know the code to accomplish it. – Greg Oct 13 '09 at 16:03
-
Option location moved in [VS 2013](http://stackoverflow.com/questions/20820358/visual-studio-2013-c-outlining-collapsing-if-else-while-code-regions): Text Editor -> C# -> View, Outline Statement Blocks. – idbrii Sep 18 '15 at 19:08
-
Can anyone explain what outlining mode is PLEASE? – Colonel Panic Jan 15 '16 at 11:02
-
This works in VS 2015 as well, which I'm grateful for! – RonC Apr 05 '16 at 19:54
The accepted answer turns off ALL code folding. If you want to disable #region folding but collapse comments, loops, methods, etc I wrote a plugin that does this for you.
Make #regions suck less (for free):
http://visualstudiogallery.msdn.microsoft.com/0ca60d35-1e02-43b7-bf59-ac7deb9afbca
- Auto Expand regions when a file is opened
- Optionally prevent regions from being collapsed (but still be able to collapse other code)
- Give the #region / #end region lines a smaller, lighter background so they are less noticeable (also an option)
- Works in C# and VB (but only in VS 2010/2012, not supported for 2008)

- 31,709
- 36
- 116
- 156
-
Any plans for a VS 2013 version? Is the source available? I'm sure someone would be willing to add 2013 support. – Chuck Conway Jun 02 '14 at 05:57
-
4
-
1@NickPainter I appreciate that this comment comes about 4 years too late, but you can get it to install on VS2017 by modifying the extension.vsixmanifest file in the DisableRegions.vsix (which is just a renamed zip file) to include additional supported versions. Please bear in mind I only tested this for like 2 mins on 1 install of VS so YMMV, but it appears to work for me. I take no responsibility if you kill your VS install though. – Ceisc Feb 26 '21 at 02:48
You can also disable region-wrapping on generated code (like when you use the Visual Studio shortcut to auto-implement an interface).

- 3,347
- 5
- 37
- 58
-
I found this at *Tools > Options > Text Editor > C# > Advanced > Implement Interface*. Uncheck *Surround generated code with #region*. Thanks again. – crush Mar 10 '14 at 15:51
It's not permanent, but the keystrokes Ctrl-M Ctrl-L expand the regions in a file

- 87,846
- 14
- 132
- 192
I've posted an answer in a related-but-not-duplicate thread that may help some people here. I detailed how to create macros that will deactivate a single unit's #regions by commenting out the #region and #endregion directives, with a companion for reactivating them. With the #regions deactivated the Ctrl+M+O / Collapse to Definitions function does exactly what I want it to. I hope this is useful for someone beside myself.
This option seem to be available only in C# and not in C/C++ (Visual Studio 2005). To disable outlining in C/C++ files you need to make a trick by changing the outlining color to editor's background color. To do this go to Tools > Options > Environment > Fonts and Colors > Collapsible Text > Change "Item Foreground" color to White (or whatever your background color is).

- 20,079
- 5
- 49
- 56
-
This! This is what I've been looking for! Really appreciate this insight into an annoying "feature" that I've been looking to kill off for months (if not years)! – jerhewet Mar 12 '12 at 15:24
-
@jerhewet by using this solution you might go into trouble if you click that white area by mistake and region folds, then to unfold it you need to aim click at an invisible area. – Czarek Tomczak Mar 12 '12 at 16:00
i resolved the problem for me with an environmentevent:
- start macroeditor (alt+f11)
- open macroproject / EnvironmentEvents
- paste the follwing code:
Private Sub DocumentEvents_DocumentOpened(ByVal Document As EnvDTE.Document) Handles DocumentEvents.DocumentOpened
If (Not Document Is Nothing) Then
If (Document.FullName.ToLower().EndsWith(".cs")) Then
Try
DTE.ExecuteCommand("Edit.ExpandAllOutlining")
Catch ex As Exception
End Try
End If
End If
End Sub
Private Sub WindowEvents_WindowActivated(ByVal GotFocus As EnvDTE.Window, ByVal LostFocus As EnvDTE.Window) Handles WindowEvents.WindowActivated
If (Not GotFocus Is Nothing) Then
If (Not GotFocus.Document Is Nothing) Then
If (GotFocus.Document.FullName.ToLower().EndsWith(".cs")) Then
Try
DTE.ExecuteCommand("Edit.ExpandAllOutlining")
Catch ex As Exception
End Try
End If
End If
End If
End Sub
Greetings Tobi

- 61
- 7