is there a way (settings? "macro"? extension?) that I can simply toggle outlining so that only the using section and my methods collapse to their signature line, but my comments (summary and double slash comments) and classes stay expanded?
Examples:
1) Uncollapsed
using System;
using MachineGun;
namespace Animals
{
/// <summary>
/// Angry animal
/// Pretty Fast, too
/// </summary>
public partial class Lion
{
//
// Dead or Alive
public Boolean Alive;
/// <summary>
/// Bad bite
/// </summary>
public PieceOfAnimal Bite(Animal animalToBite)
{
return animalToBite.Shoulder;
}
/// <summary>
/// Fatal bite
/// </summary>
public PieceOfAnimal Kill(Animal animalToKill)
{
return animalToKill.Head;
}
}
}
2) Collapsed (the following is my desired result):
using[...]
namespace Animals
{
/// <summary>
/// Angry animal
/// Pretty Fast, too
/// </summary>
public partial class Lion
{
//
// Dead or Alive
public Boolean Alive;
/// <summary>
/// Bad bite
/// </summary>
public PieceOfAnimal Bite(Animal animalToBite)[...]
/// <summary>
/// Fatal bite
/// </summary>
public PieceOfAnimal Kill(Animal animalToKill)[...]
}
}
This is how I prefer seeing my class files (the collapsed form). I've been doing the collapsing by hand a million times by now and I think there should be a way to automate/customize/extend VS to do it the way I want?
Every time I debug/hit a breakpoint, it uncollapses and messes up things. If I collapse via the context menu's collapse to outline etc. it also collapses my comments which isn't desired.
Appreciate your help!
(Ctrl+M, Ctrl+U) - Removes the outlining information for the currently selected user-defined region. Not available in Visual Basic. (Ctrl+M, Ctrl+O) - Collapses the members of all types.
How to Collapse All Source Code in VS Code? To fold all top-level and child elements of your code: Enter the command >fold and hit Enter.
CTRL + M + O will collapse all. CTRL + M + P will expand all and disable outlining. CTRL + M + M will collapse/expand the current section.
Ctrl M, Ctrl O
Collapses to definitions.
From this point a macro might not be too hard to write.
Something like find /// <summary> ...
and toggle outlining. Then lather, rinse, repeat.
Although this question is old and answered, I was looking for the same thing as question but I think this is the simpler way than writing macro:
Tools > Options > Text Editor > C# > Advanced > Outlining
> Uncheck "Show outlining for comments and preprocessor regions"
checkbox
If you do that and than use CTRL+M
and CTRL+O
shortcut, methods will collapse but summaries and regions will remain uncollapsed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With