Sublime Forum

Count lines in a project

#1

Hello everybody,

Does anyone know if there is a way (or a plugin) to count the total number of lines in a project?
I would imagine such a plugin should have some configuration file to set which extensions to scan (e.g. .php, .css) and which folders to ignore (e.g. /ExternalLibraries)

0 Likes

#2

Hey,

I don’t know any plugins that do it. I know you can do it very easily by using a regex search:

Menu > Find > Find in files…

Then turn on regular expression search (regex) and use the following values:
Find: ^(.*)$
Where: /Your/Project/Directory,*.less,*.js,*.php

Remember to NOT click on the Replace button, as it removes all lines. :blush:

Then press search. If you scroll to the bottom, you get something like “30036 matches across 282 files” That means, 30036 lines in 282 code files.

Cheers,

Jeroen Visser

0 Likes

#3

Thank you, it’s helpful :bulb:

0 Likes

#4

How would you modify this search string to exclude blank lines or even “white space” lines that have tabs or spaces but not text?

0 Likes

#5

I would just install cloc rather than trying to jerry-rig something in Sublime: cloc.sourceforge.net

0 Likes