-1

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?

  • The question is unclear. Do you mean XML comments in Visual Studio? – 273K Aug 21 '22 at 18:51
  • @273K the question is defining the 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. – Jasmine Kakarva Aug 21 '22 at 18:56
  • this works for Doxygen, I need the same solution for visual studio. – Jasmine Kakarva Aug 21 '22 at 19:25
  • I don't know what to call these comments, but I know I don't want to write the same comment multiple times for other variables if they are for the same task. – Jasmine Kakarva Aug 21 '22 at 19:30
  • @273K This [Post](https://stackoverflow.com/questions/5777982/doxygen-comment-multiple-variables-at-once) explains for doxygen, but I need this for visual studio – Jasmine Kakarva Aug 21 '22 at 19:33
  • Taking the explanation can be infinite. Could you post a [mcve], the actual comments do you have or want to have, and what is wrong with them. You always reference doxygen and visual studio, and show the working example. – 273K Aug 21 '22 at 19:42
  • 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. – Jasmine Kakarva Aug 21 '22 at 19:50
  • I want to use the following code directly in visual studio under my classes `.h` and `.cpp` where i can declare variables and write comments for them on the top of them. – Jasmine Kakarva Aug 21 '22 at 19:57
  • Sir this is me stupid, I have not mention that I need it for just commenting variables during development, and not for documentation , I am sorry for that because I made you confused – Jasmine Kakarva Aug 21 '22 at 20:07
  • Sorry, now I got it. Doxygen is a documentation generator and is confusing in the question. What you have asked, popup comments from another line, is impossible. The editor in VS shows only variable declarations and upper line comments. – 273K Aug 21 '22 at 20:09
  • @273K Sir this can be an acceptable answer, write it I will accept it as a solution, it will help others searching for the same thing. – Jasmine Kakarva Aug 21 '22 at 20:20
  • @273K or maybe you can edit my question to make it more clear, thank you – Jasmine Kakarva Aug 21 '22 at 20:22
  • If variable are related, then you can put them in a `struct`. – Phil1970 Aug 21 '22 at 21:53

1 Answers1

0

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.

273K
  • 29,503
  • 10
  • 41
  • 64