IntelliJ IDEA 2023.2 Help

Spellchecking

IntelliJ IDEA checks the spelling of all your source code, including variable names, text in strings, comments, literals, and commit messages. For this purpose, IntelliJ IDEA provides a dedicated Typo inspection which is enabled by default.

Typo quick fix

The Typo inspection detects and highlights words that are not included in any dictionary. You can either correct the spelling or save the word to the dictionary.

Correct a misspelled word

  1. Place the caret at any word highlighted by the Typo inspection.

  2. Click the Intention action button or press Alt+Enter to show the available intention actions.

  3. Select one of the suggested fixes from the list.

In string literals and comments, only the spelling of this particular word at caret changes. For code elements, such as names of variables, functions, classes, and other symbols, the inspection also suggests changing all occurrences via the Rename refactoring.

Save a word to dictionary

If a detected typo is actually a valid word, you can add it to a user-defined dictionary that extends the built-in dictionaries.

  1. Place the caret at a word highlighted by the Typo inspection.

  2. Click Intention action icon or press Alt+Enter to show the available intention actions.

  3. Select the Save to dictionary action to add the word to the user's dictionary and skip it in the future.

    If you have added the word by mistake, press Control+Z to remove it from the dictionary.

By default, IntelliJ IDEA saves words to the global application-level dictionary. You can choose to save words to the project-level dictionary if the spelling is correct only for this particular project. For more information, refer to Select the default dictionary for saving words.

Find all spelling mistakes

The Typo inspection highlights typos in the current file. You can also run the inspection on your entire project or a set of files. For more information, refer to Run a single inspection.

  1. Go to Code | Analyze Code | Run Inspection by Name… or press Control+Alt+Shift+I.

  2. In the Enter inspection name popup, find and select the Typo inspection.

  3. In the Run 'Typo' dialog, select the scope in which you want to run the inspection, and other options, such as a file mask filter. Then click OK.

IntelliJ IDEA will run the Typo inspection on all files in the selected scope and show all found typos in a separate tab of the Problems tool window.

Configure the Typo inspection

By default, the Typo inspection checks all text, including code elements, string literals, and comments in all scopes.

  1. Press Control+Alt+S to open the IDE settings and then select Editor | Inspections.

  2. Expand the Proofreading node and click Typo in the central pane.

  3. In the right-hand pane, configure the Typo inspection:

    Severity

    Specify the severity level and the scope in which to apply this level.

    For example, if you want typos to stand out more, select Error or Warning to highlight typos similar to syntax errors or warnings in your code.

    Options

    Specify the type of content to check:

    • Process code: check various code elements, such as names of classes, fields, and methods.

    • Process literals: check text inside string literals.

    • Process comments: check text inside comments.

To disable the Typo inspection entirely, clear the checkbox next to it.

Suppress the Typo inspection

Like with any other inspection, you can suppress the Typo inspection for specific files and code elements.

  1. Place the caret at a word highlighted by the Typo inspection.

  2. Click the Intention action button or press Alt+Enter to show the available intention actions.

  3. On one of the suggested fixes, press the right arrow key or click the More Actions menu and select Suppress for class or another relevant suppress action.

    How to suppress the Typo inspection

Depending on the language and code element, this adds a special annotation or comment that tells the editor to suppress the relevant inspection in the corresponding scope. For example, in case of Java, suppressing the Typo inspection for a class adds the following annotation before the class declaration:

@SuppressWarnings("SpellCheckingInspection")

This suppresses all spelling checks within the class.

For more information, refer to Suppress inspections.

Dictionaries

IntelliJ IDEA includes bundled dictionaries for all configured languages. You cannot change them directly, but you can extend the spellchecker in other ways:

  • Save words to a built-in global or project dictionary.

  • Add plain-text files with the .dic extension that contain lists of words.

  • You can add Hunspell dictionaries, each of which consists of two files: the DIC file that contains a list of words with the applicable modification rules and the AFF file that lists prefixes and suffixes regulated by a specific modification rule. For example, en_GB.dic and en_GB.aff.

Configure the spellchecker dictionaries

  1. Press Control+Alt+S to open the IDE settings and then select Editor | Natural Languages | Spelling.

  2. Configure the list of custom dictionaries:

    • To add a new custom dictionary to the list, click the Add button or press Alt+Insert and specify the location of the required file.

    • To edit the contents of a custom dictionary in IntelliJ IDEA, select it and click the Edit button or press Enter. The corresponding file will open in a new editor tab.

    • To remove a custom dictionary from the list, select it and click the Remove button or press Alt+Delete.

Select the default dictionary for saving words

By default, IntelliJ IDEA saves words to the global application-level dictionary. You can choose to save words to the project-level dictionary if the spelling is correct only for this particular project.

  1. Press Control+Alt+S to open the IDE settings and then select Editor | Natural Languages | Spelling.

  2. Select either the built-in project-level or application-level dictionary or disable the option to prompt you every time you save a word.

Add accepted words manually

  1. Press Control+Alt+S to open the IDE settings and then select Editor | Natural Languages | Spelling.

  2. Add words to the Accepted words list. IntelliJ IDEA adds manually accepted words to the project-level dictionary.

    You can't add words that are already present in one of the dictionaries and mixed-case words, such as CamelCase and snake_case.

Share dictionaries

IntelliJ IDEA stores the built-in project-level dictionary with other project-related files. This means that anyone working with the project has access to the words stored in this dictionary.

To share your application-level dictionary, use the bundled Settings Sync plugin.

Last modified: 07 September 2023