The LineCount extension for Visual Studio Code counts and displays the lines of code, the lines of comment, the lines of blank.
-
Count current file.
-
Count workspace files, 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.
-
ext install linecount
-
Through Code
Download source code and install dependencies:
git clone https://github.com/kimarudg/linecount.git
cd linecount
npm install
code .
-
LineCount.showStatusBarItem
: (boolean|defaulttrue
) Show/hide the status bar item for LineCount commands. -
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 | defaulttrue
) Whether output to TXT file. -
LineCount.output.json
: (boolean | defaulttrue
) Whether output to JSON file. -
LineCount.output.csv
: (boolean | defaultfalse
) Whether output to CSV file. -
LineCount.output.md
: (boolean | defaultfalse
) Whether output to markdown file and preview. -
LineCount.output.outdir
: (string | defaultout
) output file path. -
LineCount.sort
: (string enum | defaultfilename
) Specifies the sort field. -
LineCount.order
: (string enum | defaultasc
) 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 |defaultfalse
) 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 |defaultfalse
) Whether the block comment must be started on the line. -
LineCount.comment.separator.string.doublequotes
: (boolean |defaulttrue
) String using double quotes. -
LineCount.comment.separator.string.singlequotes
: (boolean |defaulttrue
) String using single quotes.LineCount configuration examples:
"LineCount.showStatusBarItem": 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": "-->",
}
}
]
There are two commands available.
You can access them from the command palette (Ctrl+Shift+P on Windows/Linux), or click StatusBarItem 'LineCount'.
MIT
Enjoy!