Coder Social home page Coder Social logo

vscode-linecounter's Introduction

Lines of code (linecounter)

This project is forked from LineCount project. Author of the project is not resposing any PRs or Issue and he does not developed the extesion since 1 year. So, we have published the extension under a new name.

The Lines of code extension for Visual Studio Code counts and displays the lines of code, the lines of comment, the lines of blank.

Version

Installs

Ratings


Features

  • Count the number of lines of current opened file.

  • Count the number of lines of workspace files. Also, you can custom the includes/excludes file pattern.

  • Support languages: c,cpp,java,js,ts,cs(//,/*,*/),sql(--,/*,*/),pas(//,{*,*}),perl(#,=pod,=cut),ruby(#,=begin,=end),python(#,'''),vb('),html(<!--,-->),bat(::),sh(#),ini(;),fortran(!),m(%).

  • You can customize the comment symbol, add new languages support.

  • Line number information can be output to JSON, TXT, CSV, Markdown file (MD).

Installs

  • ext install linecount

  • Through Code

    Download source code and install dependencies:

git clone https://github.com/lyzerk/vscode-linecounter.git
cd linecount
npm install
code .

Extension Settings

  • LineCount.showStatusBarItem: (boolean|default true) Show/hide the status bar item for LineCount commands.

  • LineCount.statistics: (boolean|default true) Collecting the statistics of the operation (e.g. Workspace files, Current file)

  • LineCount.includes: (string array|default "**/*") Search files pattern.

  • LineCount.excludes: (string array|default "**/.vscode/**,**/node_modules/**") files and folders that you want exclude them.

  • LineCount.output.txt: (boolean | default true) Whether output to TXT file.

  • LineCount.output.json: (boolean | default true) Whether output to JSON file.

  • LineCount.output.csv: (boolean | default false) Whether output to CSV file.

  • LineCount.output.md: (boolean | default false) Whether output to markdown file and preview.

  • LineCount.output.outdir: (string | default out) output file path.

  • LineCount.sort: (string enum | default filename) Specifies the sort field.

  • LineCount.order: (string enum | default asc) Specify ascending or descending order.

  • LineCount.comment.ext: (string array| required) file extension. if it`s "*", the rule for other files. default c style.

  • LineCount.comment.separator.linecomment: (string |default none) Single line comment symbol.

  • LineCount.comment.separator.linetol: (boolean |default false) Whether the line comment must be started on the line.

  • LineCount.comment.separator.blockstart: (string |default none) Block start comment symbol.

  • LineCount.comment.separator.blockend: (string |default none) Block end comment symbol.

  • LineCount.comment.separator.blocktol: (boolean |default false) Whether the block comment must be started on the line.

  • LineCount.comment.separator.string.doublequotes: (boolean |default true) String using double quotes.

  • LineCount.comment.separator.string.singlequotes: (boolean |default true) String using single quotes.

    LineCount configuration examples:


    "LineCount.showStatusBarItem": true,

    "LineCount.statistics": true,

    "LineCount.includes": [     
                        "**/*" 
                        ],    

    "LineCount.excludes": [ 
                         "**/.vscode/**",
                        "**/node_modules/**"
                        ],

    "LineCount.output": {
                        "txt": true,       
                        "json": true, 
                        "csv": true, 
                        "md": true,       
                        "outdir":"out"      
                        },
    "LineCount.sort": "filename",

    "LineCount.order": "asc",

    "LineCount.comment":[
                        {
                            "ext": ["c","cpp","java"], 
                            "separator": {             
                                "linecomment": "//",   
                                "linetol":false,       
                                "blockstart": "/*",    
                                "blockend": "*/",      
                                "blocktol": false,     
                                "string":{
                                    "doublequotes": true,
                                    "singlequotes": true
                                }                                
                            }
                        },
                        {
                            "ext": ["html"], 
                            "separator": {             
                                "blockstart": "<!--",    
                                "blockend": "-->",      
                            }
                        }
                     ]
        

Usage

There are two commands available.

You can access them from the command palette (Ctrl+Shift+P on Windows/Linux), or click StatusBarItem 'LineCount'.

  1. LineCount: Count current file:

Count current file

  1. LineCount: Count Workspace files:

Count workspace files

Support

Repository

License

MIT


Enjoy!

vscode-linecounter's People

Contributors

alimozdemir avatar ffengill avatar ollieday avatar yycalm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

vscode-linecounter's Issues

Does not correctly count Python """ as block comments

In Python it is legal to do block comments with either single or double quotes, eg:

def foo():
    """
    This is my docstring
    """
    pass
# code is 2 lines.
# comment is 0 line.

def bar():
    '''
    This is another docstring
    '''
    pass
# code is 2 lines.
# comment is 3 lines.

The builtinRule for 'py':
https://github.com/lyzerk/vscode-linecounter/blob/b3d2214a14249d5706adbbb7774ebadfefe4dd6f/src/LineCount.ts#L67

defines single quotes as the blockstart and blockend, so anything using double quotes for the block comments/docstrings will not be counted.

I'm not sure if it can be fixed with the current logic though. You would have to define fixed pairs of open/close blocks, not just general lists of legal blockstarts or blockends

eg, this is legal:

def foo():
    '''
    I am a docstring, I have these triple quotes in me: """
    but they don't do anything since I'm already in a docstring.
    '''
    pass

So if you allow it to eg start counting a block with ''' and end counting with """ then it will get it wrong.

Cannot turn off json output

Even if settings are like this:

    "LineCount.output": {
        "outdir": ".vscode",
        "json": "false"
    },

then linecounter.json is still generated.

Does this support specifying branch?

Thanks for sharing this great tool, while I'm using, coming up a question that if this extension supports specifying branch, as I didn't find configuration for it, thanks

Publish `lyzerk.linecounter` to Open VSX

Hi!

Thanks a lot for this nice extension. Any plans about publishing this on OpenVSX repository so that VSCodium and other clients users can use this too.

Thanks again.

Option to ignore folders

I think having the option to ignore certain folders would be handy, either from user settings, workspace settings, or direct input.

It could work like the "files to exclude" input in the search panel, allowing to ignore files or directories if its path matches the string.

.gitignore

Would be wonderful if this automatically excluded via .gitignore!

Show the project line count instead of "LineCount" in status bar

Hi. I would be great if you could see the project's line count instead of the word "LineCount" in the status bar. It could use a nice octicon or other glyph next to the count. Or it could say "Lines: 5,042"

Since it would need to keep grepping to perform a live count, this could be a option.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.