UNPKG

29.2 kBMarkdownView Raw
1# cspell
2
3[![](https://github.com/streetsidesoftware/cspell/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/streetsidesoftware/cspell/actions)
4[![Coverage Status](https://coveralls.io/repos/github/streetsidesoftware/cspell/badge.svg?branch=main)](https://coveralls.io/github/streetsidesoftware/cspell?branch=main)
5[![codecov](https://codecov.io/gh/streetsidesoftware/cspell/branch/main/graph/badge.svg?token=Dr4fi2Sy08)](https://codecov.io/gh/streetsidesoftware/cspell)
6
7A Spell Checker for Code!
8
9`cspell` is a command line tool and library for spell checking code.
10
11## Support Future Development
12
13<!--- @@inject: ../../static/sponsor.md --->
14
15- [![GitHub Sponsors](https://img.shields.io/badge/-black?style=social&logo=githubsponsors&label=GitHub%20Sponsor%3A%20Street%20Side%20Software)](https://github.com/sponsors/streetsidesoftware)
16- [![Patreon](https://img.shields.io/badge/-black?style=social&logo=patreon&label=Patreon%3A%20Street%20Side%20Software)](https://patreon.com/streetsidesoftware)
17- [![PayPal](https://img.shields.io/badge/-black?style=social&logo=paypal&label=PayPal%20Donate%3A%20Street%20Side%20Software)](https://www.paypal.com/donate/?hosted_button_id=26LNBP2Q6MKCY)
18- [![Open Collective](https://img.shields.io/badge/-black?style=social&logo=opencollective&label=Open%20Collective%3A%20CSpell)](https://opencollective.com/cspell)
19
20<!--- @@inject-end: ../../static/sponsor.md --->
21
22## Features
23
24- Spell Checks Code -- Able to spell check code by parsing it into words before checking against the dictionaries.
25 - Supports CamelCase, snake_case, and compoundwords naming styles.
26- Self contained -- does not depend upon OS libraries like Hunspell or aspell. Nor does it depend upon online services.
27- Fast -- checks 1000's of lines of code in seconds.
28- Programming Language Specific Dictionaries -- Has dedicated support for:
29 - JavaScript, TypeScript, Python, PHP, C#, C++, LaTex, Go, HTML, CSS, etc.
30- Customizable -- supports custom dictionaries and word lists.
31- Continuous Integration Support -- Can easily be added as a linter to Travis-CI.
32
33cspell was initially built as the spell checking service for the [spell checker extension](https://marketplace.visualstudio.com/items?itemName=streetsidesoftware.code-spell-checker) for
34[Visual Studio Code](https://code.visualstudio.com/).
35
36## CSpell for Enterprise
37
38<!--- @@inject: ../../static/tidelift.md --->
39
40Available as part of the Tidelift Subscription.
41
42The maintainers of cspell and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source packages you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact packages you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-cspell?utm_source=npm-cspell&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
43
44<!--- @@inject-end: ../../static/tidelift.md --->
45
46## Installation
47
48```sh npm2yarn
49npm install -g cspell
50```
51
52### Docker
53
54There is a docker image at [Packages for cspell](https://github.com/streetsidesoftware/cspell-cli/pkgs/container/cspell).
55
56`cspell` commands below can be run by replacing
57
58```
59cspell
60```
61
62with:
63
64```
65docker run -it -v $PWD:/workdir ghcr.io/streetsidesoftware/cspell:latest
66```
67
68**Example:**
69
70```sh
71docker run -it -v $PWD:/workdir ghcr.io/streetsidesoftware/cspell:latest lint --help
72```
73
74## Basic Usage
75
76Example: recursively spell check all JavaScript files in `src`
77
78**JavaScript files**
79
80```sh
81cspell "src/**/*.js"
82# or
83cspell lint "src/**/*.js"
84```
85
86**Check everything**
87
88```sh
89cspell "**"
90```
91
92**Git: Check Only Changed Files**
93
94```sh
95 git diff --name-only | npx cspell --file-list stdin
96```
97
98## Command: `lint` -- Spell Checking
99
100The `lint` command is used for spell checking files.
101
102### Help
103
104```sh
105cspell lint --help
106```
107
108### Options
109
110<!--- @@inject: static/help-lint.txt --->
111
112```
113Usage: cspell lint [options] [globs...] [file://<path> ...] [stdin[://<path>]]
114
115Patterns:
116 - [globs...] Glob Patterns
117 - [stdin] Read from "stdin" assume text file.
118 - [stdin://<path>] Read from "stdin", use <path> for file type and config.
119 - [file://<path>] Check the file at <path>
120
121Examples:
122 cspell . Recursively check all files.
123 cspell lint . The same as "cspell ."
124 cspell "*.js" Check all .js files in the current directory
125 cspell "**/*.js" Check all .js files recursively
126 cspell "src/**/*.js" Only check .js under src
127 cspell "**/*.txt" "**/*.js" Check both .js and .txt files.
128 cspell "**/*.{txt,js,md}" Check .txt, .js, and .md files.
129 cat LICENSE | cspell stdin Check stdin
130 cspell stdin://docs/doc.md Check stdin as if it was "./docs/doc.md"
131
132Check spelling
133
134Options:
135 -c, --config <cspell.json> Configuration file to use. By default cspell
136 looks for cspell.json in the current directory.
137 -v, --verbose Display more information about the files being
138 checked and the configuration.
139 --locale <locale> Set language locales. i.e. "en,fr" for English
140 and French, or "en-GB" for British English.
141 --language-id <file-type> Force programming language for unknown
142 extensions. i.e. "php" or "scala"
143 --words-only Only output the words not found in the
144 dictionaries.
145 -u, --unique Only output the first instance of a word not
146 found in the dictionaries.
147 -e, --exclude <glob> Exclude files matching the glob pattern. This
148 option can be used multiple times to add
149 multiple globs.
150 --file-list <path or stdin> Specify a list of files to be spell checked. The
151 list is filtered against the glob file patterns.
152 Note: the format is 1 file path per line.
153 --file [file...] Specify files to spell check. They are filtered
154 by the [globs...].
155 --no-issues Do not show the spelling errors.
156 --no-progress Turn off progress messages
157 --no-summary Turn off summary message in console.
158 -s, --silent Silent mode, suppress error messages.
159 --no-exit-code Do not return an exit code if issues are found.
160 --quiet Only show spelling issues or errors.
161 --fail-fast Exit after first file with an issue or error.
162 -r, --root <root folder> Root directory, defaults to current directory.
163 --no-relative Issues are displayed with absolute path instead
164 of relative to the root.
165 --show-context Show the surrounding text around an issue.
166 --show-suggestions Show spelling suggestions.
167 --no-show-suggestions Do not show spelling suggestions or fixes.
168 --no-must-find-files Do not error if no files are found.
169 --cache Use cache to only check changed files.
170 --no-cache Do not use cache.
171 --cache-reset Reset the cache file.
172 --cache-strategy <strategy> Strategy to use for detecting changed files.
173 (choices: "metadata", "content")
174 --cache-location <path> Path to the cache file or directory. (default:
175 ".cspellcache")
176 --dot Include files and directories starting with `.`
177 (period) when matching globs.
178 --gitignore Ignore files matching glob patterns found in
179 .gitignore files.
180 --no-gitignore Do NOT use .gitignore files.
181 --gitignore-root <path> Prevent searching for .gitignore files past
182 root.
183 --validate-directives Validate in-document CSpell directives.
184 --no-color Turn off color.
185 --color Force color.
186 --no-default-configuration Do not load the default configuration and
187 dictionaries.
188 --debug Output information useful for debugging
189 cspell.json files.
190 --reporter <module|path> Specify one or more reporters to use.
191 --issue-template [template] Use a custom issue template. See --help
192 --issue-template for details.
193 -h, --help display help for command
194
195More Examples:
196
197 cspell "**/*.js" --reporter @cspell/cspell-json-reporter
198 This will spell check all ".js" files recursively and use
199 "@cspell/cspell-json-reporter".
200
201 cspell . --reporter default
202 This will force the default reporter to be used overriding
203 any reporters defined in the configuration.
204
205 cspell . --reporter ./<path>/reporter.cjs
206 Use a custom reporter. See API for details.
207
208 cspell "*.md" --exclude CHANGELOG.md --files README.md CHANGELOG.md
209 Spell check only check "README.md" but NOT "CHANGELOG.md".
210
211 cspell "/*.md" --no-must-find-files --files $FILES
212 Only spell check the "/*.md" files in $FILES,
213 where $FILES is a shell variable that contains the list of files.
214
215References:
216 https://cspell.org
217 https://github.com/streetsidesoftware/cspell
218```
219
220<!--- @@inject-end: static/help-lint.txt --->
221
222## Command: `check` - Quick Visual Check
223
224Do a quick visual check of a file. This is a great way to see which text is included in the check.
225
226```sh
227cspell check <filename>
228```
229
230It will produce something like this:
231![image](https://user-images.githubusercontent.com/3740137/35588848-2a8f1bca-0602-11e8-9cda-fddee2742c35.png)
232
233### Tip for use with `less`
234
235To get color in less, use `--color` and `less -r`
236
237```sh
238cspell check <filename> --color | less -r
239```
240
241## Command: `trace` - See which dictionaries contain a word
242
243Trace shows a the list of known dictionaries and a `*` next to the ones that contain the word.
244
245A `!` will appear next to the ones where the word is forbidden.
246
247![image](https://user-images.githubusercontent.com/3740137/129488961-b99dbd2f-7daa-4462-96cd-568e0d4c3c6e.png)
248
249### Help `cspell trace --help`
250
251<!--- @@inject: static/help-trace.txt --->
252
253```
254Usage: cspell trace [options] [words...]
255
256Trace words -- Search for words in the configuration and dictionaries.
257
258Options:
259 -c, --config <cspell.json> Configuration file to use. By default cspell
260 looks for cspell.json in the current directory.
261 --locale <locale> Set language locales. i.e. "en,fr" for English
262 and French, or "en-GB" for British English.
263 --language-id <language> Use programming language. i.e. "php" or "scala".
264 --allow-compound-words Turn on allowCompoundWords
265 --no-allow-compound-words Turn off allowCompoundWords
266 --ignore-case Ignore case and accents when searching for words.
267 --no-ignore-case Do not ignore case and accents when searching for
268 words.
269 --dictionary-path <format> Configure how to display the dictionary path.
270 (choices: "hide", "short", "long", "full",
271 default: Display most of the path.)
272 --stdin Read words from stdin.
273 --all Show all dictionaries.
274 --only-found Show only dictionaries that have the words.
275 --no-color Turn off color.
276 --color Force color
277 --no-default-configuration Do not load the default configuration and
278 dictionaries.
279 -h, --help display help for command
280```
281
282<!--- @@inject-end: static/help-trace.txt --->
283
284## CI/CD Continuous Integration support
285
286### Mega-Linter
287
288[Mega-Linter](https://nvuillam.github.io/mega-linter/) aggregates 70 linters ready to use out of the box, including [cspell](https://nvuillam.github.io/mega-linter/descriptors/spell_cspell/)
289
290- Can run as a GitHub Action, on other CI tools and locally
291- Provides an updated `.cspell.json` file with new unknown words
292
293**Setup**
294
295Quick setup following installation guide in [Mega-Linter documentation](https://nvuillam.github.io/mega-linter/)
296
297### Git commit-hooks
298
299#### pre-commit
300
301**Setup**
302
303```
304npm install -SD cspell
305```
306
307**`.git/hooks/pre-commit`**
308
309```
310#!/bin/sh
311
312exec git diff --cached --name-only | npx cspell --no-summary --no-progress --no-must-find-files --file-list stdin
313```
314
315## Requirements
316
317cspell needs Node 14 and above.
318
319## How it works
320
321The concept is simple, split camelCase and snake_case words before checking them against a list of known words.
322
323- `camelCase` -> `camel case`
324- `HTMLInput` -> `html input`
325- `srcCode` -> `src code`
326- `snake_case_words` -> `snake case words`
327- `camel2snake` -> `camel snake` -- (the 2 is ignored)
328- `function parseJson(text: string)` -> `function parse json text string`
329
330### Special cases
331
332- Escape characters like `\n`, `\t` are removed if the word does not match:
333 - `\narrow` -> `narrow` - because `narrow` is a word
334 - `\ncode` -> `code` - because `ncode` is not a word.
335 - `\network` -> `network` - but it might be hiding a spelling error, if `\n` was an escape character.
336
337### Things to note
338
339- This spellchecker is case insensitive. It will not catch errors like `english` which should be `English`.
340- The spellchecker uses dictionaries stored locally. It does not send anything outside your machine.
341- The words in the dictionaries can and do contain errors.
342- There are missing words.
343- Only words longer than 3 characters are checked. "jsj" is ok, while "jsja" is not.
344- All symbols and punctuation are ignored.
345
346## In Document Settings
347
348It is possible to add spell check settings into your source code.
349This is to help with file specific issues that may not be applicable to the entire project.
350
351All settings are prefixed with `cspell:` or `spell-checker:`.
352
353- `disable` -- turn off the spell checker for a section of code.
354- `enable` -- turn the spell checker back on after it has been turned off.
355- `ignore` -- specify a list of words to be ignored.
356- `words` -- specify a list of words to be considered correct and will appear in the suggestions list.
357- `ignoreRegExp` -- Any text matching the regular expression will NOT be checked for spelling.
358- `includeRegExp` -- Only text matching the collection of includeRegExp will be checked.
359- `enableCompoundWords` / `disableCompoundWords` -- Allow / disallow words like: "stringlength".
360- `dictionaries` -- specify a list of the names of the dictionaries to use.
361
362### Enable / Disable checking sections of code
363
364It is possible to disable / enable the spell checker by adding comments to your code.
365
366#### Disable Checking
367
368- `/* cspell:disable */`
369- `/* spell-checker: disable */`
370- `/* spellchecker: disable */`
371- `// cspell:disable-line` -- disables checking for the current line.
372- `/* cspell:disable-next-line */` -- disables checking till the end of the next line.
373
374<!--- cspell:enable -->
375
376#### Enable Checking
377
378- `/* cspell:enable */`
379- `/* spell-checker: enable */`
380- `/* spellchecker: enable */`
381
382#### Example
383
384```javascript
385// cspell:disable
386const wackyWord = ['zaallano', 'wooorrdd', 'zzooommmmmmmm'];
387/* cspell:enable */
388
389const words = ['zaallano', 'wooorrdd', 'zzooommmmmmmm']; // cspell:disable-line disables this entire line
390
391// To disable the next line, use cspell:disable-next-line
392const moreWords = ['ieeees', 'beees', 'treeees'];
393
394// Nesting disable / enable is not Supported
395
396// spell-checker:disable
397// It is now disabled.
398
399var liep = 1;
400
401/* cspell:disable */
402// It is still disabled
403
404// cspell:enable
405// It is now enabled
406
407const str = 'goededag'; // <- will be flagged as an error.
408
409// spell-checker:enable <- doesn't do anything
410
411// cSPELL:DISABLE <-- also works.
412
413// if there isn't an enable, spelling is disabled till the end of the file.
414const str = 'goedemorgen'; // <- will NOT be flagged as an error.
415```
416
417<!--- cspell:enable -->
418
419### Ignore
420
421_Ignore_ allows you the specify a list of words you want to ignore within the document.
422
423```javascript
424// cspell:ignore zaallano, wooorrdd
425// cspell:ignore zzooommmmmmmm
426const wackyWord = ['zaallano', 'wooorrdd', 'zzooommmmmmmm'];
427```
428
429**Note:** words defined with `ignore` will be ignored for the entire file.
430
431### Words
432
433The _words_ list allows you to add words that will be considered correct and will be used as suggestions.
434
435```javascript
436// cspell:words woorxs sweeetbeat
437const companyName = 'woorxs sweeetbeat';
438```
439
440**Note:** words defined with `words` will be used for the entire file.
441
442### Enable / Disable compound words
443
444In some programming language it is common to glue words together.
445
446```c
447// cspell:enableCompoundWords
448char * errormessage; // Is ok with cspell:enableCompoundWords
449int errornumber; // Is also ok.
450```
451
452**Note:** Compound word checking cannot be turned on / off in the same file.
453The last setting in the file determines the value for the entire file.
454
455### Excluding and Including Text to be checked.
456
457By default, the entire document is checked for spelling.
458`cspell:disable`/`cspell:enable` above allows you to block off sections of the document.
459`ignoreRegExp` and `includeRegExp` give you the ability to ignore or include patterns of text.
460By default the flags `gim` are added if no flags are given.
461
462The spell checker works in the following way:
463
4641. Find all text matching `includeRegExp`
4651. Remove any text matching `ignoreRegExp`
4661. Check the remaining text.
467
468#### Exclude Example
469
470```javascript
471// cspell:ignoreRegExp 0x[0-9a-f]+ -- will ignore c style hex numbers
472// cspell:ignoreRegExp /0x[0-9A-F]+/g -- will ignore upper case c style hex numbers.
473// cspell:ignoreRegExp g{5} h{5} -- will only match ggggg, but not hhhhh or 'ggggg hhhhh'
474// cspell:ignoreRegExp g{5}|h{5} -- will match both ggggg and hhhhh
475// cspell:ignoreRegExp /g{5} h{5}/ -- will match 'ggggg hhhhh'
476/* cspell:ignoreRegExp /n{5}/ -- will NOT work as expected because of the ending comment -> */
477/*
478 cspell:ignoreRegExp /q{5}/ -- will match qqqqq just fine but NOT QQQQQ
479*/
480// cspell:ignoreRegExp /[^\s]{40,}/ -- will ignore long strings with no spaces.
481// cspell:ignoreRegExp Email -- this will ignore email like patterns -- see Predefined RegExp expressions
482var encodedImage = 'HR+cPzr7XGAOJNurPL0G8I2kU0UhKcqFssoKvFTR7z0T3VJfK37vS025uKroHfJ9nA6WWbHZ/ASn...';
483var email1 = 'emailaddress@myfancynewcompany.com';
484var email2 = '<emailaddress@myfancynewcompany.com>';
485```
486
487**Note:** ignoreRegExp and includeRegExp are applied to the entire file. They do not start and stop.
488
489#### Include Example
490
491In general you should not need to use `includeRegExp`. But if you are mixing languages then it could come in helpful.
492
493```Python
494# cspell:includeRegExp #.*
495# cspell:includeRegExp ("""|''')[^\1]*\1
496# only comments and block strings will be checked for spelling.
497def sum_it(self, seq):
498 """This is checked for spelling"""
499 variabele = 0
500 alinea = 'this is not checked'
501 for num in seq:
502 # The local state of 'value' will be retained between iterations
503 variabele += num
504 yield variabele
505```
506
507### Dictionaries
508
509The _dictionaries_ list allows you to specify dictionaries to use for the file.
510
511```javascript
512// cspell:dictionaries lorem-ipsum
513const companyName = 'Lorem ipsum dolor sit amet';
514```
515
516**Note:** dictionaries specified with `dictionaries` will be used for the entire file.
517
518## Predefined RegExp expressions
519
520### Exclude patterns
521
522- `Urls`<sup>1</sup> -- Matches urls
523- `HexValues` -- Matches common hex format like `#aaa`, `0xfeef`, `\u0134`
524- `Base64`<sup>1</sup> -- matches base64 blocks of text longer than 40 characters.
525- `Email` -- matches most email addresses.
526
527### Include Patterns
528
529- `Everything`<sup>1</sup> -- By default we match an entire document and remove the excludes.
530- `string` -- This matches common string formats like '...', "...", and \`...\`
531- `CStyleComment` -- These are C Style comments /\* \*/ and //
532- `PhpHereDoc` -- This matches PHPHereDoc strings.
533
534<sup>1.</sup> These patterns are part of the default include/exclude list for every file.
535
536## Customization
537
538_cspell_'s behavior can be controlled through a config file. By default it looks for any of the following files:
539
540- `.cspell.json`
541- `cspell.json`
542- `.cSpell.json`
543- `cSpell.json`
544- `cspell.config.js`
545- `cspell.config.cjs`
546- `cspell.config.json`
547- `cspell.config.yaml`
548- `cspell.config.yml`
549- `cspell.yaml`
550- `cspell.yml`
551
552Or you can specify a path to a config file with the `--config <path>` argument on the command line.
553
554### `cspell.json`
555
556#### Example `cspell.json` file
557
558```javascript
559// cSpell Settings
560{
561 // Version of the setting file. Always 0.2
562 "version": "0.2",
563 // language - current active spelling language
564 "language": "en",
565 // words - list of words to be always considered correct
566 "words": [
567 "mkdirp",
568 "tsmerge",
569 "githubusercontent",
570 "streetsidesoftware",
571 "vsmarketplacebadge",
572 "visualstudio"
573 ],
574 // flagWords - list of words to be always considered incorrect
575 // This is useful for offensive words and common spelling errors.
576 // For example "hte" should be "the"
577 "flagWords": [
578 "hte"
579 ]
580}
581```
582
583### cspell.json sections
584
585- `version` - currently always 0.2 - controls how the settings in the configuration file behave.
586
587- `language` - this specifies the language locale to use in choosing the general dictionary.
588 For example: `"language": "en-GB"` tells cspell to use British English instead of US English.
589
590- `words` - a list of words to be considered correct.
591
592- `flagWords` - a list of words to be always considered incorrect
593
594- `ignoreWords` - a list of words to be ignored (even if they are in the flagWords).
595
596- `ignorePaths` - a list of globs to specify which files are to be ignored.
597
598 **Example**
599
600 ```json
601 "ignorePaths": ["node_modules/**"]
602 ```
603
604 will cause cspell to ignore anything in the `node_modules` directory.
605
606- `maxNumberOfProblems` - defaults to **_100_** per file.
607
608- `minWordLength` - defaults to **_4_** - the minimum length of a word before it is checked.
609
610- `allowCompoundWords` - defaults to **_false_**; set to **true** to allow compound words by default.
611
612- `dictionaries` - list of the names of the dictionaries to use. See [Dictionaries](#Dictionaries) below.
613
614- `dictionaryDefinitions` - this list defines any custom dictionaries to use. This is how you can include other languages like Spanish.
615
616 **Example**
617
618 ```javascript
619 "language": "en",
620 // Dictionaries "spanish", "ruby", and "corp-term" will always be checked.
621 // Including "spanish" in the list of dictionaries means both Spanish and English
622 // words will be considered correct.
623 "dictionaries": ["spanish", "ruby", "corp-terms", "fonts"],
624 // Define each dictionary. Relative paths are relative to the config file.
625 "dictionaryDefinitions": [
626 { "name": "spanish", "path": "./spanish-words.txt"},
627 { "name": "ruby", "path": "./ruby.txt"},
628 { "name": "company-terms", "path": "./corp-terms.txt"}
629 ],
630 ```
631
632- `ignoreRegExpList` - list of patterns to be ignored
633
634- `includeRegExpList` - _(Advanced)_ limits the text checked to be only that matching the expressions in the list.
635
636- `patterns` - this allows you to define named patterns to be used with
637 `ignoreRegExpList` and `includeRegExpList`.
638
639- `languageSettings` - this allow for per programming language configuration settings. See [LanguageSettings](#LanguageSettings)
640
641## Dictionaries
642
643The spell checker includes a set of default dictionaries.
644
645### General Dictionaries
646
647- **en_US** - Derived from Hunspell US English words.
648- **en-gb** - Derived from Hunspell GB English words.
649- **companies** - List of well known companies
650- **softwareTerms** - Software Terms and concepts like "coroutine", "debounce", "tree", etc.
651- **misc** - Terms that do not belong in the other dictionaries.
652
653### Programming Language Dictionaries
654
655- **typescript** - keywords for TypeScript and JavaScript
656- **node** - terms related to using nodejs.
657- **php** - _php_ keywords and library methods
658- **go** - _go_ keywords and library methods
659- **python** - _python_ keywords
660- **powershell** - _powershell_ keywords
661- **html** - _html_ related keywords
662- **css** - _css_, _less_, and _scss_ related keywords
663- **cpp** - _C++_ related keywords
664- **csharp** - _C#_ related keywords
665- **latex** - LaTex related words
666- **bash** - Bash/shell script keywords
667
668### Miscellaneous Dictionaries
669
670- **fonts** - long list of fonts - to assist with _css_
671- **filetypes** - list of file types
672- **npm** - list of top 500+ package names on npm.
673
674### Dictionary Definition
675
676- **name** - The reference name of the dictionary, used with program language settings
677- **description** - Optional description
678- **path** - Path to the file, can be relative or absolute. Relative path is relative to the
679 current `cspell.json` file.
680- **repMap** - Optional replacement map use to replace character prior to searching the dictionary.
681 Example:
682 ```javascript
683 // Replace various tick marks with a single '
684 "repMap": [["'|`|’", "'"]]
685 ```
686 // Use Compounds
687- **useCompounds** - allow compound words
688
689```javascript
690// Define each dictionary. Relative paths are relative to the config file.
691"dictionaryDefinitions": [
692 { "name": "spanish", "path": "./spanish-words.txt"},
693 { "name": "ruby", "path": "./ruby.txt"},
694 { "name": "company-terms", "path": "./corp-terms.txt"}
695],
696```
697
698### Disabling a Dictionary
699
700It is possible to prevent a dictionary from being loaded. This is useful if you want to use your own dictionary or just
701turn off an existing dictionary.
702
703#### Disable Default cpp Dictionary
704
705```javascript
706"dictionaries": ["!cpp"],
707"overrides": [
708 {
709 "filename": "legacy/**/*.cpp",
710 "dictionaries": ["!!cpp"], // add it back for *.cpp files under the legacy folder
711 },
712]
713```
714
715The number of `!`s is important.
716
717- `!cpp` remove `cpp` dictionary
718- `!!cpp` add it back
719- `!!!cpp` remove it again.
720
721## LanguageSettings
722
723The Language Settings allow configuration to be based upon the programming language and/or the locale.
724There are two selector fields `locale` and `languageId`.
725
726- `languageId` defines which programming languages to match against.
727 A value of `"python,javascript"` will match against _python_ and _javascript_ files. To match against ALL programming languages,
728 use `"*"`.
729- `locale` defines which spoken languages to match against. A value of `"en-GB,nl"` will match against British English or Dutch.
730 A value of `"*"` will match all spoken languages.
731- Most configuration values allowed in a `cspell.json` file can be define or redefine within the `languageSettings`.
732
733```javascript
734 "languageSettings": [
735 {
736 // VSCode languageId. i.e. typescript, java, go, cpp, javascript, markdown, latex
737 // * will match against any file type.
738 "languageId": "c,cpp",
739 // Language locale. i.e. en-US, de-AT, or ru. * will match all locales.
740 // Multiple locales can be specified like: "en, en-US" to match both English and English US.
741 "locale": "*",
742 // To exclude patterns, add them to "ignoreRegExpList"
743 "ignoreRegExpList": [
744 "/#include.*/"
745 ],
746 // List of dictionaries to enable by name in `dictionaryDefinitions`
747 "dictionaries": ["cpp"],
748 // Dictionary definitions can also be supplied here. They are only used iff "languageId" and "locale" match.
749 "dictionaryDefinitions": []
750 }
751 ]
752```
753
754## Overrides
755
756Overrides are useful for forcing configuration on a per file basis.
757
758Example:
759
760```javascript
761 "overrides": [
762 // Force `*.hrr` and `*.crr` files to be treated as `cpp` files:
763 {
764 "filename": "**/{*.hrr,*.crr}",
765 "languageId": "cpp"
766 },
767 // Force `*.txt` to use the Dutch dictionary (Dutch dictionary needs to be installed separately):
768 {
769 "language": "nl",
770 "filename": "**/dutch/**/*.txt"
771 }
772 ]
773```
774
775<!--- @@inject: ../../static/footer.md --->
776
777<br/>
778
779---
780
781<p align="center">Brought to you by<a href="https://streetsidesoftware.com" title="Street Side Software"><img width="16" alt="Street Side Software Logo" src="https://i.imgur.com/CyduuVY.png" /> Street Side Software</a></p>
782
783<!--- @@inject-end: ../../static/footer.md --->
784
785<!---
786 cspell:disableCompoundWords
787 cspell:ignore compoundwords stringlength errornumber
788 cspell:ignore jsja goededag alek wheerd behaviour tsmerge QQQQQ ncode
789 cspell:includeRegExp Everything
790 cspell:ignore hte variabele alinea
791 cspell:ignore mkdirp githubusercontent streetsidesoftware vsmarketplacebadge visualstudio
792 cspell:words Verdana
793 cspell:ignore ieeees beees treeees
794 cspell:ignore amet
795-->