Table of Contents
VS Code Guide
How to Count Lines in VS Code: Every Method Explained
Count lines in VS Code without plugins using the status bar, keyboard shortcuts, and terminal. Plus: count lines across an entire project, exclude comments, and compare extensions.
You open a file in VS Code. You look at the bottom status bar.
You see: Ln 847, Col 12.
Great. You know you are on line 847. But how many lines does the file have?
You scroll to the bottom. Ln 2,341. OK.
Now your manager asks: "How many lines of code does this entire project have?"
You stare at the status bar. It stares back.
That is why "count lines in VS Code" is not one question. It is three different questions:
- How many lines are in the current file?
- How many lines did I select?
- How many lines of code are in the whole project?
This guide splits those intents apart first, then gives you the native VS Code methods, terminal commands, and extension options for each one. If you are counting text outside the editor, the browser-based Line Counter tool is faster. If you need to count lines in VS Code for source files, selections, or a whole workspace, start here.
Choose Your Line Count in 3 Seconds
Jump to the right answer
If you need a quick VS Code line count for one open file, the answer is already in the status bar. If you need count lines of code VS Code project results, use the terminal or a code-counting extension. If you need selected lines, VS Code can do it, but the native behavior is less obvious than it should be. The sections below show how to count lines in VS Code without installing anything first.
Part 1: How to See the Total Line Count of the Current File
Part 1 conclusion
For the current file, VS Code show total lines behavior is native: look at the bottom status bar when no text is selected.
Method 1A: Read the Status Bar
The fastest way to count lines in VS Code is to do nothing. Open a file and look at the bottom status bar.
Status bar:
Ln 847, Col 12 2341 lines Spaces: 2 UTF-8 LF TypeScript
| |
current cursor total file line count
position this is the number you want
Ln 847, Col 12 is not the file total. It means the cursor is currently on line 847, column 12. The separate 2341 lines item is the total number of lines in the file. This is the simplest native VS Code line count method.
The catch: 2341 lines appears when you do not have text selected. Once you select text, that area can change to selection information such as characters, ranges, or multiple selections. If you are trying to make VS Code show total lines and the number disappeared, click once in the editor to clear the selection. For current files, this is the most reliable way to count lines in VS Code.
Method 1B: Jump to the Last Line
If the total line item is hidden or you just want a keyboard-only check, jump to the end of the file:
Windows/Linux: Ctrl + End
macOS: Cmd + Down
After the cursor moves to the bottom, read the Ln number in the status bar. If it says Ln 2341, the file has 2,341 lines.
The official VS Code keyboard shortcuts reference lists Ctrl+End on Windows/Linux and Cmd+Down on macOS for moving to the bottom of the file, and Ctrl+G / Control+G for Go to Line. See the VS Code default keybindings reference if your keymap differs.
Method 1C: Use Go to Line with a Huge Number
This trick is useful when you want a fast count without scrolling.
Windows/Linux: Ctrl + G
macOS: Control + G
Then type: 999999
VS Code cannot go past the end of the file, so it jumps to the last real line. The Ln value in the status bar is your total. This is a practical fallback when the status bar total is not visible or when you are using a narrow window.
Part 2: How to Count Selected Lines in VS Code
Part 2 conclusion
VS Code selection counting is the confusing part. Native VS Code often emphasizes characters and selections, so exact selected-line counting depends on how you select the text.
This is where many users get frustrated. You select multiple lines and expect a simple "12 lines selected" message. Instead, the status bar may show character counts or a selection range. That is why people looking for a VS Code word count extension often end up needing a line-count or selection-count extension instead.
The pain is not imaginary. A long-running community complaint, summarized by Jürgen Gmach's write-up on how to count selected lines in VS Code, points to multiple closed VS Code issues and workarounds. The practical answer is: use native readouts when they match your selection style, or install a small extension when you need this constantly.
Method 2A: Read the Native Selection Status
When you select complete lines, VS Code can show selection information in the status bar. Depending on the selection shape and version, you may see readouts such as:
1 selection 5 lines selected
or selection position details instead of a plain line total. The important detail is that full-line selections are easier to count than partial character selections. If you drag from the middle of one line to the middle of another, VS Code may treat the selection as a character range rather than a clean line selection.
For the most reliable native reading:
- Start at the beginning of the first line.
- Select through the end of the final line.
- Avoid starting or ending the selection in the middle of a line.
- Read the selection item in the status bar.
This method works for quick checks, but it is not the best answer if selected-line counts are part of your daily workflow.
Method 2B: Convert the Selection into Whole Lines
You can use built-in selection commands to make the selection line-based before reading the status bar.
1. Select the target region.
2. Open Command Palette:
Windows/Linux: Ctrl + Shift + P
macOS: Cmd + Shift + P
3. Search for line selection commands such as "Expand Line Selection".
4. Read the updated selection information in the status bar.
This is useful when the current selection starts or ends mid-line. It also helps when you are counting CSV fields where each generated field lives on one physical line.
Method 2C: Copy the Selection into a New File
This is blunt, but it works without extensions.
1. Select the code.
2. Copy it.
3. Create a new untitled file:
Windows/Linux: Ctrl + N
macOS: Cmd + N
4. Paste.
5. Read the total line count in the new file's status bar.
Use this when you need one answer and do not want to install anything. It is especially reliable for generated text, SQL output, CSV rows, and copied logs.
Method 2D: Install a Lightweight Selection Counter
If you need selected-line counts all the time, use an extension dedicated to the status bar readout. Good options include selection-count or status-bar extensions that show selected lines, words, and characters.
The selection-count category overlaps with word-count extension search intent because many extensions expose lines, words, and characters in one status bar item. For code editing, choose an extension that explicitly supports selected lines, not just words or characters.
Look for these features:
- Shows selected line count in the status bar.
- Handles partial-line and full-line selections clearly.
- Does not require a full project scan.
- Has recent maintenance and a simple permission surface.
Part 3: How to Count Lines of Code Across an Entire VS Code Project
Part 3 conclusion
For a whole project, use terminal commands when you need reproducible output, VS Code Counter for a UI report, and cloc or tokei when you need code/comment/blank-line classification.
This is the biggest difference between a current-file VS Code line count and a project metric. The status bar only knows about the current editor. A project-level answer must walk the workspace, include and exclude files, and decide whether comments and blank lines count. To count lines in VS Code across a repository, you need a workspace-aware method.
Method 3A: Use the Integrated Terminal
Open the integrated terminal from the workspace root:
Windows/Linux: Ctrl + `
macOS: Control + `
On macOS and Linux, use find plus wc -l:
# Count all JavaScript files.
find . -name "*.js" -not -path "*/node_modules/*" -not -path "*/.git/*" -print0 \
| xargs -0 wc -l
For multiple file types:
find . \( -name "*.js" -o -name "*.ts" -o -name "*.jsx" -o -name "*.tsx" \) \
-not -path "*/node_modules/*" \
-not -path "*/dist/*" \
-not -path "*/.git/*" \
-print0 | xargs -0 wc -l
For a rough single-language count with grep:
grep -r "" --include="*.ts" --exclude-dir=node_modules --exclude-dir=.git . | wc -l
On Windows PowerShell:
(Get-ChildItem -Recurse -Include *.js,*.ts,*.jsx,*.tsx -File |
Where-Object { $_.FullName -notmatch '\\node_modules\\|\\.git\\|\\dist\\' } |
Get-Content |
Measure-Object -Line).Lines
Terminal commands are the best first answer for count lines of code VS Code project when you do not want extensions. They are reproducible, can be pasted into documentation, and can run in CI.
For more command-line options, see the cross-platform guide to count lines with wc -l. If your count depends on runtime-generated text, the JavaScript guide explains how to count lines in JavaScript with strings, files, streams, and browser uploads.
Method 3B: Use the VS Code Counter Extension
If you want a visual report inside the editor, the VS Code Counter Marketplace page is the main extension to know. As of May 12, 2026, it lists 796,027 installs and describes itself as a source-code line counter for many programming languages.
Install it:
1. Open Extensions:
Windows/Linux: Ctrl + Shift + X
macOS: Cmd + Shift + X
2. Search for "VS Code Counter".
3. Choose "VS Code Counter" by Kentaro Ushiyama.
4. Install it.
Use it for a workspace:
Command Palette:
VSCodeCounter: Count lines in workspace
Use it for a folder:
Explorer sidebar:
Right-click a folder -> Count lines in directory
Typical report shape:
Language | Files | Blank | Comment | Code
-------------|-------|-------|---------|------
TypeScript | 42 | 892 | 234 | 8,431
JavaScript | 18 | 312 | 89 | 2,847
CSS | 8 | 156 | 12 | 934
Markdown | 12 | 445 | 0 | 1,203
-------------|-------|-------|---------|------
Total | 80 | 1,805 | 335 |13,415
The VS Code Counter extension is useful because it counts blank lines, comment lines, and physical source lines. Its Marketplace documentation also lists workspace counting, directory counting, current-file real-time counting, selected-range counting, .gitignore support, files.exclude support, CSV output, Markdown output, text output, and Remote Development configuration support.
This is the most practical GUI answer when someone asks for a code-counting extension recommendation.
Method 3C: Use cloc
For professional code metrics, use cloc.
# npm
npm install -g cloc
# macOS with Homebrew
brew install cloc
Run it from the VS Code integrated terminal:
cloc .
Exclude generated or vendored folders:
cloc . --exclude-dir=node_modules,dist,.git
Only include specific languages:
cloc . --include-lang=JavaScript,TypeScript
The cloc documentation lists --exclude-dir=<D1>[,D2,] and --include-lang=<L1>[,L2[...]], so this syntax is script-friendly and easy to audit. Use cloc when a project report needs to separate code, comments, and blank lines.
Example output:
-------------------------------------------------------------------------------
Language files blank comment code
-------------------------------------------------------------------------------
TypeScript 42 892 234 8431
JavaScript 18 312 89 2847
-------------------------------------------------------------------------------
SUM: 60 1204 323 11278
-------------------------------------------------------------------------------
Method 3D: Use tokei
tokei is another strong command-line option. It is known for speed and clean output across many languages.
tokei .
Use it when you want a fast local summary and do not need the output shape of cloc.
Project-Wide Method Comparison
| Method | Install cost | Visual report | Scriptable | Excludes comments/blanks | Best use |
|---|---|---|---|---|---|
wc -l / PowerShell | None | No | Yes | No | Quick physical line count |
| VS Code Counter | Extension | Yes | Limited | Yes | Daily editor-based reports |
cloc | npm, brew, package manager | No | Yes | Yes | CI, audits, project reports |
tokei | package manager | No | Yes | Yes | Fast local summaries |
If you need count lines of code VS Code project output for a manager, use cloc or VS Code Counter. If you just need a quick rough total, wc -l is enough. This is the point where "count lines in VS Code" becomes a project reporting task rather than an editor status-bar task.
Part 4: Advanced Line Counting Scenarios in VS Code
Count Only Code Lines, Not Comments or Blank Lines
Use cloc for language-aware results:
cloc . --by-file --exclude-dir=node_modules,dist,.git
For a quick one-file approximation in TypeScript:
grep -v '^\s*$' src/index.ts | grep -v '^\s*//' | wc -l
That grep command excludes blank lines and simple // comments, but it does not understand block comments, strings that contain //, or language-specific syntax. Use it for rough checks only.
Compare Line Count Between Two Git Versions
Git can show added and removed lines between versions:
# Compare the working tree with the previous commit.
git diff HEAD~1 --stat
# Show line changes for one commit.
git show --stat abc1234
# Show numeric insertions/deletions by file.
git diff --numstat HEAD~1 HEAD
This answers a different question than VS Code show total lines. Git tells you what changed, not the total size of the project. If you want to analyze generated text or API output instead, use the JavaScript article on how to count lines in JavaScript.
Show Real-Time Counts in the Status Bar
VS Code Counter includes a real-time counter feature. Open the Command Palette and run:
VSCodeCounter: Toggle Real-time Counter Visibility
The Marketplace page says it can count the code lines of the current file in real time and count the range of selected text. This is the closest extension-based answer to a persistent VS Code line count dashboard in the status bar.
Choose Between Line Count, Word Count, and Character Count Extensions
Search results for VS Code word count extension often mix writing tools with coding tools. For Markdown, documentation, and prose, a word-count extension may be correct. For source code, choose tools that count files, blank lines, comments, and code lines.
Use this quick rule:
| Need | Better tool |
|---|---|
| Markdown words or article length | Word-count extension |
| Current file physical lines | Native VS Code status bar |
| Selected code line count | Selection-count status bar extension |
| Project code/comment/blank report | VS Code Counter, cloc, or tokei |
That distinction keeps word-count extension search from sending you to a prose tool when you really need a code metric.
FAQ
How do I see total line count in VS Code status bar?
Clear any text selection and look at the bottom status bar. Ln X, Col Y shows where the cursor is. The separate Z lines item is the total number of lines in the current file. If that Z lines item is hidden, jump to the last line with Ctrl+End on Windows/Linux or Cmd+Down on macOS and read the Ln number.
Why does VS Code show characters instead of lines when I select text?
VS Code's native status bar has historically emphasized selection state and selected character information. For exact selected-line counts, select whole lines, copy the selection into a new untitled file, or install a selection-count extension. The community has discussed this behavior for years, and many users still find it surprising.
How do I count lines of code in an entire VS Code project?
Use the integrated terminal or a project-counting extension. The no-extension path is find ... | xargs wc -l on macOS/Linux or Get-ChildItem ... | Measure-Object -Line in PowerShell. For classified code/comment/blank counts, use cloc, tokei, or the VS Code Counter extension.
What is the best VS Code extension for counting lines?
For project-wide code reports, use VS Code Counter. It supports workspace and directory counting, current-file real-time counts, output formats, and ignore settings. For selected-line counts only, a smaller selection-count extension may be enough.
How do I exclude node_modules when counting lines?
With cloc, run:
cloc . --exclude-dir=node_modules,dist,.git
With find, add -not -path "*/node_modules/*". With VS Code Counter, enable .gitignore and files.exclude support or configure its include and exclude patterns.
Can I count only code lines, not comments or blank lines?
Yes. Use cloc, tokei, or VS Code Counter. Plain wc -l counts physical lines, so comments and blank lines are included.
How do I count lines in VS Code without an extension?
For a single file, use the status bar, Ctrl+End / Cmd+Down, or Ctrl+G / Control+G. For a project, use terminal commands from the workspace root. Those native paths cover most cases where you need to count lines in VS Code without adding extensions.
Sources Checked
- VS Code Counter Marketplace page for install count, commands, feature list, output formats,
.gitignore, and Remote Development notes. - VS Code default keybindings reference for Go to Line and file-end shortcuts.
- cloc npm documentation for
--exclude-dirand--include-langsyntax. - Jürgen Gmach's selected-line-count note for the community pain point around selected line counts.
Related Guides and Tools
- Vim line count guide if you need the same answer inside a terminal editor.
- Count lines with wc -l for command-line methods on Linux, macOS, and Windows.
- Count lines in JavaScript when you need to count strings, files, streams, or browser uploads in code.
- Python line counting guide for Python scripts, large files, directories, and CLI implementations.
- Online text tools for browser-based text cleanup and counting.
- Line Counter tool for pasted text, uploaded files, and non-code content.
Working with Text Outside VS Code?
If you are counting lines in pasted text, uploaded files, CMS content, exported logs, or email drafts rather than source code in an editor, the Line Counter tool handles it instantly in the browser.
No install. No extension. No terminal.
Quick CTA
Working with text outside VS Code? Paste it into the Line Counter tool and get line, word, character, and paragraph counts instantly.
Frequently Asked Questions
How do I see total line count in VS Code status bar?
Look at the bottom status bar when no text is selected. Ln X, Col Y is the cursor position. The separate Z lines item is the total file line count. If text is selected, that area changes to selection information.
Why does VS Code show characters instead of lines when I select text?
VS Code's native status bar prioritizes selection size and cursor/selection state. For exact selected-line counts, use the status bar's selection readout when selecting whole lines, copy the selection into a new untitled file, or install a selection-count extension.
How do I count lines of code in an entire VS Code project?
Open the integrated terminal and run wc -l, PowerShell Measure-Object, cloc, or tokei from the workspace root. If you prefer a UI report, install VS Code Counter and run Count lines in workspace or Count lines in directory.
What is the best VS Code extension for counting lines?
VS Code Counter is the best general-purpose choice for project line reports because it counts files, blank lines, comment lines, and code lines, supports directory counting, and can export text, CSV, or Markdown reports.
How do I exclude node_modules when counting lines?
Use find paths that exclude node_modules, run cloc with --exclude-dir=node_modules,dist,.git, or enable VS Code Counter settings that use .gitignore and files.exclude.
Can I count only code lines, not comments or blank lines?
Yes. Use cloc, tokei, or VS Code Counter. Plain wc -l counts physical lines, so it does not separate code, blank, and comment lines.
How do I count lines in VS Code without an extension?
For the current file, use the status bar or jump to the last line. For a project, use the integrated terminal with find plus wc -l on macOS/Linux or PowerShell Get-ChildItem plus Measure-Object on Windows.
Related Guides
16 min read
How to Count Lines in Bash: The Complete Guide with Edge Cases
Master line counting in Bash: count lines in files, variables, command output, and directories. Covers wc -l pitfalls, empty files, filenames with spaces, and shell script usage.
18 min read
How to Count Lines in JavaScript: 6 Methods with Performance Benchmarks
Count lines in JavaScript strings, files, Node.js streams, and the browser. Includes real performance benchmarks, edge case handling, and a decision guide for every scenario.
18 min read
How to Count Lines in a File on Linux, macOS, and Windows
Count lines in any file on Linux, macOS, or Windows using wc -l, PowerShell, CMD, and GUI tools. Includes large file methods, CSV row counting, and cross-platform scripts.
20 min read
How to Count Lines in Python: 7 Methods, Benchmarked and Battle-Tested
Count lines in Python strings, text files, large files, and directories. Includes real performance benchmarks, empty file handling, splitlines vs split, and production-ready functions.