43

title says everything plus: - development language Lua - code revision control system - Perforce (integrated with IntelliJ IDE)

Skippy le Grand Gourou
7,8526 gold badges65 silver badges81 bronze badges
asked Feb 3, 2012 at 10:05
2
  • 1
    Related: stackoverflow.com/questions/3435581/… Commented Nov 6, 2014 at 17:21
  • You should change the accepted answer, even @duffymo the author of the currently accepted answer says so in the comments below. Commented Dec 28, 2023 at 0:25

2 Answers 2

96

You can hack it via the native, global search:

  1. Ctrl + Shift + F (to open global search)
  2. Use regex mode (check the .* checkbox)
  3. In the searchbox, enter only a caret "^" (without the quotes)
  4. You may want to limit the search to a specific directory, via the "directory" tab
  5. Hit the "Open in Find Window" button on the bottom-right
  6. If it asks whether you want to continue, press "Continue"

The number of lines is shown at the end of the "Found occurrences" sentence.

Notes:

  • In regex, the caret (^) denotes the start of a line, except when inside square brackets, in which case it denotes negation
  • If you wanted to count non-empty lines, you could instead use "^.*\S" (without quotes), which signifies "The start of a line (^), followed by any number of characters (except newline) (.*), followed by a non-whitespace character (\S)"

Gloabal search for Lines of Code

Skippy le Grand Gourou
7,8526 gold badges65 silver badges81 bronze badges
answered Feb 27, 2020 at 5:39
Sign up to request clarification or add additional context in comments.

3 Comments

Had this answer shown up 8 years earlier it would have been the accepted answer.
Eight years later. I'd accept this answer, too. I don't use the statistics plugin anymore, but I do use this answer.
With larger projects, this can be a lot slower than the statistic plugin.
41

You can either turn on the display of lines of code for a single file by right clicking in the left gutter and highlighting "display lines of code". Or you can do it for your entire project by downloading the Statistic plug-in. It's very nice indeed, because it shows LOC and other metrics for your entire project.

answered Feb 3, 2012 at 10:08

5 Comments

The Statistic plug-in also counts every line in the branch/tags folder, even if they are excluded from the project.
I don't know what "excluded from the project" means. When I check out a project I do it in such a way that only that branch or tag is visible to IntelliJ. That's the only way that makes sense to me.
For large multi-module project you may want to have the branches and tags checked out to quickly be able to switch between them. Each sub-module has a trunk/branch. The plugin seems to choose the project root directory and count all the files contained within, disregarding whether or not that subfolder is actually used in the project at all. There is a feature in IntelliJ where you can "Mark Directory As/Excluded" from the workspace manually but the plugin doesn't seem to use this information at all.
I've installed the plugin but how option in the menu can I use to bring the statistics dialog up?
Go to View->Tool Windows->Statistic. I'm running it in IntelliJ 16.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.