Overview
This plugin provides:- Word count: Total words in the current document
- Character count (optional): Total characters with or without spaces
- Real-time updates: Statistics update as you type
- Markdown-aware: Strips syntax for accurate counts
- Status bar integration: Always visible while editing
packages/plugins/src/word-count/WordCountPlugin.ts:1-25
Features
Word Count
Counts words in the active document:- Removes code blocks and inline code (not prose)
- Removes image syntax
- Keeps link text but removes URLs
- Removes formatting characters
- Splits by whitespace
- Counts non-empty words
packages/plugins/src/word-count/WordCountPlugin.ts:147-163
Character Count
Counts characters with optional space exclusion:- With spaces: Total characters including whitespace
- Without spaces: Only visible characters
packages/plugins/src/word-count/WordCountPlugin.ts:168-175
Markdown-Aware Counting
The word counter intelligently handles markdown: Code blocks - Excluded from count:Real-Time Updates
Word count updates automatically every 500ms:packages/plugins/src/word-count/WordCountPlugin.ts:93-98
Settings
Available Settings
packages/plugins/src/word-count/WordCountPlugin.ts:6-16
Settings UI
Access settings at Settings → Plugins → Word Count:- Show word count: Toggle word count display
- Show character count: Toggle character count display
- Count spaces: Include spaces in character count
Settings Tab Implementation
packages/plugins/src/word-count/WordCountSettingTab.ts
Status Bar Integration
The plugin adds a status bar item:packages/plugins/src/word-count/WordCountPlugin.ts:76-88
Display Format
Word count only:Update Logic
packages/plugins/src/word-count/WordCountPlugin.ts:113-143
Implementation Details
Plugin Lifecycle
packages/plugins/src/word-count/WordCountPlugin.ts:26-54
EditorAdapter Usage
The plugin usesEditorAdapter for cross-platform compatibility:
- Desktop: DOM-based CodeMirror
- Mobile: React Native implementation
packages/plugins/src/word-count/WordCountPlugin.ts:117-125
Settings Persistence
packages/plugins/src/word-count/WordCountPlugin.ts:59-71
Performance
Update Frequency
- Update interval: 500ms (0.5 seconds)
- CPU impact: Minimal - simple string operations
- Memory impact: Negligible - no caching
Optimization Strategies
- Debouncing: Only updates twice per second
- Early returns: Skips update if no editor is active
- Efficient regex: Pre-compiled patterns
- No DOM updates: Only updates when count changes
Performance with Large Documents
For a 10,000-word document:- Counting time: < 5ms
- Memory usage: < 1MB temporary
- UI impact: None (runs in background)
Installation
The Word Count plugin is built-in and enabled by default. To toggle it:- Open Settings → Plugins
- Find “Word Count”
- Toggle the enable switch
Use Cases
Writing Goals
Track progress toward word count goals:Academic Writing
Ensure papers meet requirements:- Abstract: 150-250 words
- Body: 3,000-5,000 words
- Conclusion: 200-300 words
Content Creation
Optimize for platforms:- Blog post: 1,000-2,000 words
- Twitter thread: 280 chars per tweet
- Newsletter: 500-800 words
Translation
Character counts for translation pricing:- Many translation services charge per character
- Useful to estimate costs
Troubleshooting
Word count not updating
Solutions:- Check the plugin is enabled
- Ensure an editor is active (not in file browser)
- Check settings - word count display might be disabled
- Restart Inkdown
Count seems inaccurate
Reasons:- Code blocks are excluded - this is intentional
- URLs are excluded - this is intentional
- Hyphenated words - counted as separate words
- Numbers - counted as words
Character count doesn’t match other tools
Reasons:- Spaces setting - check “Count spaces” setting
- Line endings - different tools count differently
- Unicode characters - may count differently
Status bar item not visible
Solutions:- Check status bar is enabled (View → Show Status Bar)
- Check plugin is enabled
- Resize window (status bar may be hidden on small screens)
- Check other plugins aren’t hiding it
API Reference
Plugin Class
packages/plugins/src/word-count/WordCountPlugin.ts:26-176
Settings Interface
Status Bar Item API
Future Enhancements
Potential future features:Reading Time Estimate
Selection Count
Show word count for selected text:Target Goal Tracking
Per-Section Counts
Show counts for current section/heading:Export Statistics
Generate detailed statistics:- Words per heading
- Average sentence length
- Reading level
- Vocabulary diversity
See Also
Status Bar API
Status bar integration guide
Plugin Settings
Creating plugin settings
Editor Adapter
Cross-platform editor access
Plugin Development
Create custom plugins
