# Code style

> For the complete documentation index, see [llms.txt](https://www.jetbrains.com.cn/en-us/help/go/llms.txt).

> **TL;DR**
> Open settings by pressing `Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `Ctrl+Comma` (VSCode), `⌘ Comma` (VSCode (macOS)) and navigate to `Editor | Code Style`.

If certain coding guidelines exist in a company, one has to follow these guidelines when creating source code. GoLand helps you maintain the required code style.

The IDE comes with two pre-defined schemes: the Project scheme and the Default scheme.

* In the Project scheme, the settings that you configure apply only to your current project. These settings are stored in the `codeStyles` folder under `.idea` and are shared through VCS together with the project. The IDE creates the folder after you modify code style settings for your project.

* In the Default scheme (IDE-level scheme), the settings that you configure apply to all existing projects that have the Default code style scheme selected. These settings are stored in the `codestyles` folder under the GoLand [configuration directory](directories-used-by-the-ide-to-store-settings-caches-plugins-and-logs.html) and are not shared through VCS.

If you want to use the project code style scheme as your default scheme, you can copy it to the IDE level. The other way around is also possible: you can overwrite your current project settings with the settings from an IDE-level scheme and share them with other members of your team.

> **Note:**
> There can be only one Project code style scheme. On the IDE level, you can have multiple schemes. Several projects can refer to the same IDE-level code style scheme.

## Configure schemes

In GoLand, code style settings are language-specific, so you need to configure them for every language that you use in your project separately. You can also copy the settings from one language and apply them to another language.

Procedure: Create a new code style scheme

To create a new code style scheme, duplicate an existing IDE-level scheme and then configure the duplicate according to your needs.

1. Press `Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `Ctrl+Comma` (VSCode), `⌘ Comma` (VSCode (macOS)) to open settings and then select `Editor | Code Style`.

Here you can configure general code style settings.

If you want to create a code style for a specific language, select this language from the list.

2. Select one of the existing schemes stored in the IDE and click ![Show Scheme Actions](https://resources.jetbrains.com.cn/help/img/idea/2026.3/app.expui.general.settings.svg) Show Scheme Actions.

3. From the list, select Duplicate to create a copy of the scheme.

![Creating a new code style scheme](https://resources.jetbrains.com.cn/help/img/idea/2026.3/ij_create_code_style.png)

4. Name the new scheme and press `Enter` (Windows), `⏎` (macOS), `⏎` (IntelliJ IDEA Classic (macOS)), `⏎` (macOS System Shortcuts), `Enter` (XWin), `Enter` (GNOME), `Enter` (KDE), `Enter` (Emacs), `Enter` (Sublime Text), `⏎` (Sublime Text (macOS)), `Enter` (VSCode), `⏎` (VSCode (macOS)) to save it.

After that, you can configure the settings in the new scheme.

Procedure: Configure code style for a language

1. Press `Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `Ctrl+Comma` (VSCode), `⌘ Comma` (VSCode (macOS)) to open settings and then select `Editor | Code Style`.

To configure a scheme [for new projects](configure-project-settings.html#new-default-settings),  go to `File | New Projects Setup | Settings for New Projects | Editor | Code Style`.

2. Select the language for which you want to configure the code style.

3. Select the code style Scheme that you want to configure: the [Project](#project-scheme) scheme or one of the [IDE-level scheme](#default-scheme).

> **Tip:**
> Click ![Show Scheme Actions](https://resources.jetbrains.com.cn/help/img/idea/2026.3/app.expui.general.settings.svg) Show Scheme Actions next to the Default scheme and select Duplicate to create a copy of the scheme.

4. Browse through the tabs and configure code style preferences.

Use the right section of the dialog to preview the changes. When you change a setting, one or several blinking areas appear in the preview area emphasizing the changes.

Procedure: Disable code formatting in a scope

1. In Settings `Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `Ctrl+Comma` (VSCode), `⌘ Comma` (VSCode (macOS)), select `Editor | Code Style`.

2. Click the Formatter tab.

3. In the Do not format field, specify a [glob pattern](https://en.wikipedia.org/wiki/Glob_(programming)) with the names of files and directories that you want to exclude from [reformatting](reformat-and-rearrange-code.html), [code
arrangement](null), and [import optimization](creating-and-optimizing-imports.html#optimize-imports) , for example: `*.{html,htm}`.

You can specify several glob patterns separated with a semicolon `;`.

Use the asterisk `*` wildcard to disable reformatting altogether.

[Video](https://resources.jetbrains.com.cn/help/img/idea/2026.3/go_disable_formatting_in_scope.mp4)

Procedure: Apply code style from another language

For most of the supported languages, you can copy code style settings from other languages or frameworks.

> **Note:**
> Copying styles between languages is not supported for C#, Visual Basic, and other .NET-specific languages.

1. Press `Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `Ctrl+Comma` (VSCode), `⌘ Comma` (VSCode (macOS)) to open settings and then select `Editor | Code Style`.

To configure a scheme [for new projects](configure-project-settings.html#new-default-settings),  go to `File | New Projects Setup | Settings for New Projects | Editor | Code Style` in the main menu.

2. Select the language for which you want to configure the code style.

3. Select the code style Scheme that you want to modify: the [Project](#project-scheme) scheme or one of the [IDE-level scheme](#default-scheme).

4. Click Set from in the upper-right corner.

The link is shown only if it is possible to apply code style settings from another language.

5. From the list that appears, select the language to copy the code style from.

> **Note:**
> Only applicable settings are copied from another language, other settings are left intact.

## Manage code style on a directory level with EditorConfig

> **Note:**
> To use EditorConfig,      make sure the  EditorConfig plugin is enabled in the settings.  Press `Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `Ctrl+Comma` (VSCode), `⌘ Comma` (VSCode (macOS)) to open settings and then select `Plugins`.  In the search field, type EditorConfig. For more information about plugins, refer to [Managing plugins](managing-plugins.html).

GoLand allows you to manage all code style settings for each individual set of files with [EditorConfig](https://editorconfig.org/) support (enabled by default   in the Settings dialog (`Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `Ctrl+Comma` (VSCode), `⌘ Comma` (VSCode (macOS)))). All you need to do is place an `.editorconfig` file in the root directory containing the files whose code style you want to define. You can have as many `.editorconfig` files within a project as needed, so you can specify different styles for different modules.

All options from the `.editorconfig` file are applied to the directory where it resides as well as all of its sub-directories on top of the current project code style. If anything is not defined in `.editorconfig`, it's taken from the project settings.

All options in the `.editorconfig` file are divided into the following categories:

* Standard options such as `indent_size`, `indent_style`, and so on. These options do not have any domain-specific prefixes.

* Generic IntelliJ options that have the `ij_` prefix and are applicable to all languages: * `ij_visual_guides` * `ij_formatter_off_tag` * `ij_formatter_on_tag` * `ij_formatter_tags_enabled` * `ij_wrap_on_typing` * `ij_continuation_indent_size` * `ij_smart_tabs`

* Common IntelliJ options supported by many (but not all) languages. They start with the `ij_any` prefix, for example, `ij_any_brace_style`.

* IntelliJ language-specific options starting with the `ij_<lang>_` prefix where `<lang>` is the language domain ID (normally a low-case language name), for example, `ij_java_blank_lines_after_imports`.

> **Note:**
> The same options can be defined as a common option and a language-specific option, for example, `ij_<...>_brace_style`. Language-specific options have higher priority over common or generic options.

Procedure: Add an .editorconfig file

1. In the Project view, right-click a source directory containing the files whose code style you want to define and choose `New | EditorConfig` from the context menu.

2. Select the properties that you want to define so that GoLand creates stubs for them, or leave all checkboxes empty to add the required properties manually.

3. To preview how changes to your code style settings will impact the actual source files, click ![the eye icon](https://resources.jetbrains.com.cn/help/img/idea/2026.3/app.actions.show.svg) in the gutter of the `.editorconfig` file and select a source file affected by it. The preview will open on the right.

![editorconfig preview](https://resources.jetbrains.com.cn/help/img/idea/2026.3/go_editor_config_visual_guides.png)

You can make changes in the preview pane to try and test how your configuration changes are reflected without worrying about making unwanted changes to the source code: all these changes are discarded when you close the `.editorconfig` file.

## Productivity tips

Procedure: Wrap call arguments, function parameters, and composite literal elements

* To configure wrapping for call arguments, function parameters, and composite literal elements, open settings by pressing `Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `Ctrl+Comma` (VSCode), `⌘ Comma` (VSCode (macOS)) and navigate to `Editor | Code Style | Go | Wrapping and Braces`. .

![Code formatting: wrapping for call arguments, function parameters, and composite literal elements](https://resources.jetbrains.com.cn/help/img/idea/2026.3/go_code_formatting_wrapping.png)

Procedure: Wrap arguments by using intention actions

* To wrap arguments in the function signature, place the caret before the opening bracket, call the intention action by pressing `Alt+Enter` (Windows), `⌥ ⏎` (macOS), `⌥ ⏎` (IntelliJ IDEA Classic (macOS)), `⌥ ⏎` (macOS System Shortcuts), `Alt+Enter` (XWin), `Alt+Enter` (GNOME), `Alt+Enter` (KDE), `Alt+Enter` (Emacs), `Alt+Enter` (Sublime Text), `⌥ ⏎` (Sublime Text (macOS)), `Ctrl+.` (VSCode), `⌘ .` (VSCode (macOS)), and select Put arguments on separate lines. To revert this action, press `Alt+Enter` (Windows), `⌥ ⏎` (macOS), `⌥ ⏎` (IntelliJ IDEA Classic (macOS)), `⌥ ⏎` (macOS System Shortcuts), `Alt+Enter` (XWin), `Alt+Enter` (GNOME), `Alt+Enter` (KDE), `Alt+Enter` (Emacs), `Alt+Enter` (Sublime Text), `⌥ ⏎` (Sublime Text (macOS)), `Ctrl+.` (VSCode), `⌘ .` (VSCode (macOS)) and select Put arguments on one line.

![intention_actions_for_wrapping](https://resources.jetbrains.com.cn/help/img/idea/2026.3/go_intention_actions_for_wrapping.png)

## See also

### Procedures

[EditorConfig](editorconfig.html) [Write and edit source code](working-with-source-code.html)  [Reformat code](reformat-and-rearrange-code.html)

### Reference

[Code Style](settings-code-style.html)

