This is a lightweight extension developed for VS Code and Open VSX-compatible IDEs. It is specifically designed for the precise word counting of English words in LaTeX documents (.tex files) by filtering out comments, numbers, and symbols. This helps researchers keep track of their prose word count to comply with strict word limit requirements set by major journals.
Features
This extension works exclusively on LaTeX (.tex) files to offer academic writing assistance:
LaTeX Exclusive: Only runs on files with a .tex extension or when the language mode is set to LaTeX. It keeps your status bar clean when editing other programming files.
Auto Word-Wrap: When you open a LaTeX file, the extension automatically checks if word wrapping is enabled. If disabled, it auto-enables word wrap ("editor.wordWrap": "on") for the current language mode, ensuring a seamless editing and reading experience.
Real-time Count: Displays the number of English words in the selected text in the bottom status bar dynamically.
Accurate Filtering: Ignores Chinese characters, punctuation marks, numbers, and other non-English symbols. Only genuine English words (including common abbreviations like don't, it's) are counted.
LaTeX Comment Filtering: Automatically filters out unescaped % comments. Words inside comments are completely ignored to ensure an accurate count of the actual paper prose.
Auto-hide: The status bar counter automatically hides when there is no active text selection.
Detailed Popup: Clicking on the status bar counter triggers an information dialog displaying the detailed English word count.
Local Development & Debugging
If you need to modify or debug this extension locally, follow these steps:
Open the project directory in VS Code.
Press F5 (or click Run and Debug in the sidebar) to launch a new VS Code Extension Development Host window.
In the new window, open any LaTeX (.tex) file.
Select text with your mouse and observe the word count displayed in the bottom-right status bar.
Packaging & Installation
To package this extension into a .vsix file for distribution or local usage, follow these steps:
Install the @vscode/vsce packaging tool globally:
npm install -g @vscode/vsce
Navigate to the extension's root directory english-word-counter.
Run the packaging command:
vsce package
This will generate a file named english-word-counter-1.2.0.vsix in the current directory.
Install the extension:
Open VS Code and navigate to the Extensions sidebar.
Click the "..." menu in the top-right corner and select Install from VSIX....
Select the packaged english-word-counter-1.2.0.vsix file to complete the installation.