GoLand 2023.3 Help

Grammar

GoLand checks the grammar of text files, such as your project's README.md. You can also configure it to check various textual elements in your source code: string literals, comments, and even your commit messages. It highlights mistakes related to morphology, punctuation, the overall structure, and style.

By default, GoLand includes English language support and suggests adding another language if it detects one. For more information about supported languages and how to add them, refer to Natural languages.

GoLand checks grammar using the Grammar inspection. Press Control+Alt+S to open the IDE settings and select Editor | Inspections. The Grammar inspection is under Proofreading. By default, it is set to the lowest severity level (subtle underline) and is applied in all scopes.

proofreading section in settings

Fix grammar mistakes

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

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

  3. Select the proper fix from the list of suggestions.

Intention action to fix the mistake

Besides applying the fix, you can either disable the rule that triggered the inspection or add the detected phrase as an exception.

Scope of grammar checks

You can configure the types of files and specific code constructs where you want to check grammar. For example, you can enable grammar checks in Markdown files, in strings and comments of Go files, and disable grammar checks for YAML and JSON.

Configure where to check grammar

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

  2. On the Scope tab, select the code constructs where you want to check grammar and the types of files for which you want to enable grammar checks.

    Option

    Description

    String literals

    Check grammar in string literals.

    Comments

    Check grammar in generic line and block comments.

    Documentation

    Check grammar in embedded code documentation.

    Commit messages

    Check grammar in commit messages for the configured VCS. If you enable this, GoLand adds the corresponding inspection tool to the .idea/vcs.xml configuration file.

Grammar rules

GoLand checks grammar against a set of rules defined for a language. For example, in English, there are rules on how to properly use articles, commas, and past tense forms, stylistic hints for creative and plain writing, common typos and words that are commonly confused, proper collocations, and many more.

Most of these rules are enabled by default and detect definite mistakes. However, some of them are suggestions that you may not agree with or not care about. In this case, you can disable a specific rule from the intention action or in the settings.

Intention action to disable the rule

Configure the set of rules

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

  2. On the Rules tab, select the rules against which you want to check your text.

Use the search field to filter the list of rules with a keyword, such as article or comma.

Exceptions

Exceptions are words and phrases that you want to be always considered correct. If some rule triggers a mistake in a phrase that you do not want to highlight, you do not need to disable this rule, because then it will not be triggered in other places where the rule is valid. In this case, you can add the phrase as an exception using the intention action.

Intention action to add an exception

Review all added exceptions

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

  2. On the Exceptions tab, you can see the list of words and phrases added as exceptions. Remove an exception by selecting it and clicking the Remove button.

Last modified: 11 December 2023