Select Edit -> Find & Replace -> Find in files... or just press CTRL+SHIFT+F
Check Use and select Regular expressions.
Type the following as the text to find:
C#
^~(:Wh@//.+)~(:Wh@\{:Wh@)~(:Wh@\}:Wh@)~(:Wh@/#).+VB.NET (thanks Steve for the info!)
^~(:Wh@'.+)~(:Wh@/#).+
Select where you want to do the search/count: file, project or solution.
If you select Current project or Entire solution, you also need to specify the file types that will be included in the search.

Proceed with the "search" and at the bottom of the Find results window you will see the total line count.

The regular expression that is used match every line that are not a comment (//), a compiler directive (starts with #), a single opening or closing brace, or blank lines.
Note:
This post is based on this one from Philip Stears (the regex in the original post does not work correctly).
12 comments:
OMFG :O What a monster ;)
Awesome! Thanks!
:D works perfect! Thanks a bunch...
That's a great tip - thanks! I've just reported our teams numbers back to our supervisor - maybe we'll get a break now..
Awesome. Love this.
^~(:Wh@'.+)~(:Wh@/#).+
The above regex should work for VB.NET
I've updated the post. Thanks for the info Steve.
Note that the term (:Wh@/#) above should probably be (:Wh@\#) for C++ at least. Exchange the right slash for the left slash (escape) character so that the compiler directives are skipped.
Also note that this regular expression will count multi-line comments without leading special characters as source code. In any case German's tip will give you a fast, rough estimate.
That's awesome! Easy and helpful, thank's a lot.
Hmm.. det rejser helt sikkert visse emner.
Bedste hilsner,
Nickie, frokostordning
nice
Post a Comment