Question

I'm trying to find an easy way to find the number of comment-lines in an IDL file and I don't want to install another extension just for this (also: I don't have Code Analysis, so no metrics). It occurred to me that Visual Studio supports regex searches in the Find In Files search window. So could I count the number of comment-lines in my IDL file using a straightforward regex search?

Unfortunately I am not fluent in regex at all, so the next question is: what would the regex pattern have to be? And if this is any easier: a line with code and a comment appended should count as code and not as comment. Please also beer in mind that Visual Studio has its own regex standard.

Here are some typical examples of comments in the IDL file:

// comment
//++ comment

UserMode,             // comment

/*++
comment
--*/

I think the comments that contain ++ and/or -- are some auto-generated comments.

Was it helpful?

Solution

Its Simple.

  1. Find : /\*.*\*/
  2. Repace : anything

  3. Then give replace All.

  4. You will find the count , in a message box 9 matches replaced. You now got the count.
  5. Undo the entire operation, by ctrl + Z

Edit : Response for comment that it is not working.

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top