views:

103

answers:

3

Is there a way to "collapse" functions and values in VS2008, like one would do for objects in languages like C#? It's incredibly time-consuming and frustrating to wade through hundreds of lines of nested function definitions.

+1  A: 

No there is not in Visual Studio 2008 because the language service does not support outlining. It also does not in Visual Studio 2010. However the editor supports the notion of adhoc / custom outlining.

  • Select a region in the editor
  • Right click and go to Outlining -> Hide Selection

Unfortunately this is a completely manual process.

JaredPar
On VS2010, someone wrote a simple outliner extension here (http://visualstudiogallery.msdn.microsoft.com/en-us/bec977b8-c9d9-4926-999e-e50c4498df8a). It's based entirely on indentation rather than language syntax, but with F# being mostly indentation sensitive (with light syntax), it works pretty well. I've not got any major complaints about it.
Mark H
+7  A: 

So, the official answer is that this is not supported. However, when I was doing an internship with the F# team, I wrote a prototype implementation of this feature. Because the F# team had other more important things to do, this was never properly tested and it was not included in the final version.

The code for the feature is actually still present in F# and the feature can be turned on by adding the following to the devenv.exe.config file:

<appSettings>
    <add key="fsharp-regions-enabled" value="true" />
</appSettings>

Apparently, it's not exactly what you wanted, because you can only collapse modules and type definitions, but it could still be useful - it is difficult to decide what to make collapsible in F#, because F# has so many nested declarations...

BTW: Did I mention that this is not tested and it can crash Visual Studio or even collapse the universe?

Tomas Petricek
Oow, a singularity feature!
gradbot
If it collapses the universe, I shall be very _put out_.
Joel Mueller
A: 

I have come with something that works for me and will maybe interest you. I have VS2008+RockScroll (Works On My Machine).

It really helps when I have to deal with loads of nested functions because I see much better the whole picture. Also I do a comment at the start of the body of the function, like:

// Start of bigFunctionWithLoadsOfNestedFunctions

When double-clicking on it, it both highlights in red the let-bound definition and the real start of the function in the thumbnail view. See: http://img338.imageshack.us/img338/1060/40105807.png

Stringer Bell