How to count lines of Java code using IntelliJ IDEA?
9 Answers
The Statistic plugin worked for me.
To install it from Intellij:
File - Settings - Plugins - Browse repositories... Find it on the list and double-click on it.
Access the 'statistic' toolbar via tabs in bottom left of project
OLDER VERSIONS: Open statistics window from:
View -> Tool Windows -> Statistic
In the past I have used the excellently named MetricsReloaded plugin to get this information.
You can install it from the JetBrains repository.
Once installed, access via: Analyze -> Calculate Metrics...
Statistic plugins works fine!
Here is a quick case:
- Ctrl+Shift+A and serach for "Statistic" to open the panel.
- You will see panel as the screenshot and then click
Refresh
for whole project or select your project or file andRefresh on selection
for only selection.
now 2 versions of metricsreloaded available. One supported on v9 and v10 isavailable here http://plugins.intellij.net/plugin/?idea&id=93
You can to use Count Lines of Code (CLOC)
On Settings
-> External Tools
add a new tool
- Name: Count Lines of Code
- Group: Statistics
- Program: path/to/cloc
- Parameters: $ProjectFileDir$ or $FileParentDir$
To find all including empty lines of code try @Neil's solution:
Open Find in Path (Ctrl+Shift+F)
Search for the following regular expression: \n'
For lines with at least one character use following expression:
(.+)\n
For lines with at least one word character or digit use following expression:
`(.*)([\w\d]+)(.*)\n`
Notice: But the last line of file is just counted if you have a line break after it.