Home > Software design >  Visual Studio comment multiple variables at once?
Visual Studio comment multiple variables at once?

Time:08-22

variables comment method in which a group of variables receive the same comment if the variables declared in a class is for the same task, I don't want to write the same comment for each variable , it make the code dirty.

Comment Hover Pop Up

declare 5 variables of int type in a row, give a comment description to the first variable and the other 4 variables should take the comment from the first variable , when you mouse hover on any of the variable in visual studio , it should show the comment from the first variable.

In doxygen we do something like

/*! \name This will be the description for the following group of variables
          It can be arbitrarily long, but the first line will show up in bold,
          and any subsequent lines will show up like a description under it
*/
//@{
int relatedVariable1;
int relatedVariable2;
char* relatedVariable3;
//@}

How to achieve something same in visual studio if possible?

CodePudding user response:

What you are asking, is the IntelliSense's task QuickInfo. It shows tooltips, and comments there that are followed by declarations, if the mouse pointer is above their usages.

It's not well documented, I could not find more useful info. But I found an reported issue, that complains about not shown comment in a tooltip, if a comment and a declaration are split even by an empty line.

Thus, I come to a conclusion, what you have asked is impossible - any comment detached from a declaration will not be shown in a tooltip. In your example, the second and third variables are detached from the comment above the first variable declaration.

  • Related