How do I show how many lines of code my project contains in Visual Studio?

KingNestor picture KingNestor · May 6, 2009 · Viewed 54.1k times · Source

Possible Duplicate:
How do you count the lines of code in a Visual Studio solution?

How can I show the code metrics window in Visual Studio 2008 Professional SP1? I'm looking to see how many total lines of code my project is for school and I can't find it.

The help file said to go to View->Other Windows->Code Metrics, but this option is not available to me. I also tried right-clicking the project in the Solution Explorer to see if there was an option but there wasn't.

Where is this mythical unicorn of a feature? If the Pro version doesn't have this feature has anyone found a simple external method to count the lines in all .cs files in an automated way?

Answer

Lei picture Lei · Jan 6, 2010

You don't need 3rd party tools, just press CTRL+SHIFT+F, and in the window that pops up choose "use regular expression". Use this Regular Expression:

^:b*[^:b#/]+.*$

For Visual Studio 2012 and above the regular expression is:

^(?([^\r\n])\s)*[^\s+?/]+[^\n]*$