2023/05/12

Using the VSCode extension "Code Spell Checker"


If you install Code Spell Checker, it will check spelling in real-time and highlight typos with wavy underlines.

How to use

You just install it, and it will notify you of spelling mistakes with wavy underlines.

display typo

Spelling mistakes are also displayed in the Problems tab.

display typo 2

Moreover, Code Spell Checker provides suggestions for correct alternatives.
You can place the cursor on the misspelled word, then click on 'Quick Fix' or the lightbulb icon to view the suggested corrections.

How to view suggestions for spelling mistakes in Code Spell Checker

Setting up spell-checking rules

Here is how to set up check rules for your own use or share them with your team.

using the settings file

There are 3 configuration files for Code Spell Checker.
The numbers below indicate the priority order.

  1. Creating a 'cspell.json' file in the Workspace Folder and configuring it.
  2. Configuring it through VSCode's Workspace Settings.
  3. Configuring it through VSCode's User Settings.

For option 1, you create the file manually.
For options 2 and 3, you can edit the files directly or use VSCode's settings interface.


Creating cspell.json

You can write the following in a JSON file format.
The following is a list of items that may be used frequently.

Setting Description
words zzzzz Registers 'zzzzz' as a dictionary word and includes it in the suggestions for corrections
ignoreWords zzzzz Excludes 'zzzzz' from spell checking
flagWords zzzzz Forces 'zzzzz' to be considered an error
allowCompoundWords Enables support for Hungarian notation (words written in Hungarian notation like 'spellcheck' would normally be flagged as errors but will not be flagged when this setting is enabled)
ignorePaths Specifies file paths to be excluded from spell checking
maxNumberOfProblems Specifies the maximum number of spelling mistakes to display
minWordLength Specifies the minimum number of alphabets for spell checking English words, The default value is 4

For example, you can use it as follows:

{
    "words": [
        "aiueo"
    ],
    "ignoreWords": [
        "testword"
    ],
    "flagWords": [
        "spellCheck"
    ],
    "allowCompoundWords": true,
    "ignorePaths": [
        "xxxxxx/**"
    ],
    "maxNumberOfProblems": 4,
    "minWordLength": 7
}

For other settings, please refer to the following:

Setting from the settings page

In the extension settings page within VSCode, you can configure settings for both Workspace Settings and User Settings.

code spell checker setting

You can configure the same settings that can be set in the cspell.json file through the VSCode settings.
There are a total of 59 items available.

Settings from the right-click menu

You can right-click on a flagged word and then choose the option to add the word to the dictionary.

code spell checker setting 2

You can also use shortcuts to perform these actions:

Settings within your code

By commenting out the line 'cSpell: xxxxx' within your code, you can configure specific rules.
Replace 'xxxxx' with the following settings:

setting description
disable Turns off spell checking functionality after this line
enable Turns on spell checking functionality after this line, Used in conjunction with 'disable'
disable-next-line Turns off spell checking functionality for the next line only
ignore zzzzz Excludes 'zzzzz' from spell checking
flag zzzzz Forces 'zzzzz' to be considered an error
words zzzzz Registers 'zzzzz' as a dictionary word and includes it in the suggestions for corrections
enableCompoundWords Enables support for Hungarian notation

For example, you can use it as follows

/* cSpell:disable */
spell chek    ←This will not be checked
/* cSpell:enable */



Comment (github account is required)