What is a vocabulary?
A vocabulary is a directory containing two text files:accept.txt: Terms that are always correctreject.txt: Terms that should never be used
Creating a vocabulary
Create a directory structure under yourStylesPath:
accept.txt format
List terms to accept, one per line:Accepted patterns
Accepted patterns
- Plain text: Exact matches (e.g.,
GitHub) - Regex patterns: Any valid regular expression
- Case-insensitive: Use
(?i)flag (e.g.,(?i)GitHubmatches “github”, “GITHUB”, “GitHub”) - Comments: Lines starting with
#are ignored - Blank lines: Ignored
testdata/fixtures/vocab/styles/config/vocabularies/Basic/accept.txt):reject.txt format
List terms to reject, one per line:testdata/fixtures/vocab/styles/config/vocabularies/Basic/reject.txt):
Keep
reject.txt simple. For sophisticated term replacement, create a substitution rule in your style instead.Activating a vocabulary
Activate vocabularies in your.vale.ini file:
styles/config/vocabularies/MyProject/.
Multiple vocabularies
Combine multiple vocabularies:How vocabularies integrate with rules
Vocabularies automatically affect three built-in Vale rules:- Vale.Spelling
- Vale.Terms
- Vale.Avoid
Terms in If your Vale won’t flag these as misspellings.
accept.txt are added to the spelling dictionary.accept.txt contains:Using vocabularies in custom rules
Custom rules can access vocabulary terms via thevocab option:
vocab: true, terms in your accept.txt are automatically added to the rule’s exceptions list.
From internal/check/definition.go:42, most rules default to Vocab: true:
Disabling vocabulary integration
Disabling vocabulary integration
Set Now the rule flags “API” and “SDK” even if they’re in
vocab: false to prevent vocabulary terms from affecting a rule:accept.txt.Vocabulary loading
Vale loads vocabularies during initialization:Parse configuration
Vale reads the
Vocab key from .vale.ini and identifies which vocabularies to load.Locate directories
For each vocabulary name, Vale searches for
config/vocabularies/{name}/ under each StylesPath.Read files
Vale reads
accept.txt and reject.txt from each vocabulary directory.From internal/core/ini.go:29-58:Examples
- Software project
- Marketing content
- Multi-vocabulary setup
Best practices
Keep vocabularies focused
Keep vocabularies focused
Separate vocabularies by domain:
Base: Common terms across all contentAPI: API-specific terminologyLegal: Legal and compliance termsMarketing: Brand and marketing language
Use regex patterns sparingly
Use regex patterns sparingly
Regex patterns are powerful but can slow down Vale’s performance:Use plain text entries when possible.
Document your vocabulary
Document your vocabulary
Add comments explaining why terms are included:
Keep reject.txt minimal
Keep reject.txt minimal
Use
reject.txt for terms that are universally wrong in your context. For nuanced replacements, create substitution rules:Version control vocabularies
Version control vocabularies
Commit vocabularies to version control alongside your styles:This keeps terminology in sync with your content.
Troubleshooting
Vocabulary not loading
Vocabulary not loading
Check the directory structure:Look for “AcceptedTokens” and “RejectedTokens” in the output. If empty, Vale isn’t finding your vocabulary.Common issues:
- Wrong directory name (must match
Vocabvalue in config) - Missing
config/vocabularies/intermediate directories - Files named incorrectly (must be
accept.txtandreject.txt)
Terms still flagged
Terms still flagged
If Vale still flags terms in
accept.txt:- Check the rule: Some rules set
vocab: false - Verify the term format: Ensure proper escaping for special characters
- Check rule scope: The rule might not apply to your content’s scope
- Reload Vale: Restart your editor or Vale server after changing vocabulary files
Regex pattern not matching
Regex pattern not matching
Test your regex pattern:If the pattern works in the rule but not in the vocabulary, check for special characters that need escaping.
Advanced usage
Conditional vocabulary loading
Conditional vocabulary loading
Use different vocabularies for different file types:
Shared vocabularies across projects
Shared vocabularies across projects
internal/core/ini.go:29-58, internal/core/config.go:324-346, internal/check/definition.go:341-373