If you collapse a block of commented-out code in Visual Studio, it's pretty normal. You get the little box containing [ // ... ]
to indicate that there is a collapsed comment, and you can mouse over it to see a little pop-up of what's inside. Instead of having to mouse-over each time, is there a way to just add a single-line comment above or below the [ // ... ]
block without Visual Studio trying to include it in the collapsed section?
For example, when trying to do the following:
//this is a brief description of the collapsed code below
[ // ... ]
Visual Studio then forces the upper comment into the collapsed section below, rendering it useless unless you mouse-over it. So that saves some time potentially, but doesn't eliminate the need to mouse-over; sometimes, it's just easier to read one line to remember what something does, and all the better if you don't have to jump through an extra hoop to read that one line.
You could just do something like this by skipping a line:
//this is a brief description of the collapsed code below
[ // ... ]
And it works the way that I'd want it to -- without collapsing everything together -- but that extra line space in between just looks weird, and having to do that potentially multiple times in a program just makes the whole thing longer. Any advice?
If you want a comment to serve as reminder or summary text for another block of collapsed comment code, say in the event that you want to hold onto some code before determining whether or not to edit it or delete it, it can be done in one of at least two ways in Visual Studio. First, the obvious difference between comment types:
There is a difference in the way that the Visual Studio IDE handles the two comment types. Single-line comments may stand alone, or could be grouped together with other single-line comments to form a collapsible block, but the block cannot be separated into groups of single-line comments without skipping lines in-between. Multi-line comments can always be collapsed, but their indicators /* */
are paired, similar to how the { }
symbols are paired in code.
That said, comment types can be combined in at least the following ways to form reminders/summaries.
First:
which collapses like so:
and second:
which collapses like so:
Note again that multi-line comments can always be collapsed, so it might be easy in longer bits of code to lose track of line locations if they are collapsed accidentally.