To exclude specific files or directories from spell-check warnings or errors in Visual Studio Code we can use both the `cSpell.ignorePaths` and `cSpell.enabled ` settings. You can configure these settings in your `settings.json file`. The `cSpell.enabled` setting allows you to enable or disable the Code Spell Checker (cSpell) extension globally, and the `cSpell.ignorePaths` setting lets you specify which files or folders should be exempt from spell checking [2]. Follow these steps to achieve this:
1. Install the Code Spell Checker (cSpell) Extension: If you haven't already, install the Code Spell Checker (cSpell) extension from the Visual Studio Code Marketplace.
2. Open Your Settings: Open your VS Code settings by going to File -> Preferences -> Settings, or by using the shortcut Ctrl + , (Cmd + , on macOS).
3. Edit settings.json: In the settings, click on the `Edit in settings.json` link located at the top-right corner of the settings page.
4. Configure cSpell.enabled: To globally enable or disable the Code Spell Checker extension, set the `cSpell.enabled` option to true or false in your`settings.json` file. Here's an example of how to disable spell checking [1]:
```json
{
// Enable cSpell
"cSpell.enabled": true,
// Specify which language IDs should have spell checking enabled
"cSpell.enabledLanguageIds": [
"markdown",
"plaintext"
],
// Define a list of regular expressions to ignore during spell checking
"cSpell.ignoreRegExpList": [
// Ignore lines that start with one or more digits followed by a period and a space
// This is useful for ignoring numbered lists in Markdown or similar formats
"^\\s*\\d+\\.\\s"
]
}
```
This will turn off spell checking for all files by default.
5. Configure cSpell.ignorePaths: To specify files or folders that should be excluded from spell checking, configure the `cSpell.ignorePaths` setting. For example, if you want to ignore all files within a node_modules folder:
```json
{
// Exclude spell checking in paths containing "node_modules"
"cSpell.ignorePaths": [
"**/node_modules/**"
]
}
```
You can tailor this setting to align with your specific needs by adding patterns for the files or folders you wish to exclude.
6. Save settings.json: After configuring both `cSpell.enabled` and `cSpell.ignorePaths`, save the `settings.json` file.
7. Reload the Workspace: To apply the changes, you may need to reload your workspace or reopen the files that you want to exclude from spell checking.