Line count without empty lines

  • Proxy

    Proxy - 2012-02-29

    In order to make code readable everyone uses empty lines or comment lines. Considering my application it would be very useful to know the exact number of code lines without empty lines and comment lines(which start with # char). Is there any possibility I can do that with Notepad++. Ideally I would like that to appear directly in the left sidebar like the classic line count but counting just the lines that actually contain code.

    Let me know if you have ideas on how I could do that.
    Thank you

  • JimD

    JimD - 2012-05-16

    You can use GNU AWK (gawk):

    ( ) C:> type test.txt
    # This line (and all the blank ones) does not count.
    Code {
      this is code too
      and this
    # Another comment
    Last code line.
    ( ) C:\> gawk "NF && $1 !~ /^#/ { count++ } END { print count }" test.txt
    ( ) C:>

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks