GoLand 2024.2 Help

Indentation

Indentation settings are configured for every programming language separately.

GoLand displays the indentation information in the status bar. So, if your project has files of different types, the easiest way of learning the current indentation style and accessing the corresponding settings is to use the Indentation widget.

Indentation widget

Configure indentation style

In GoLand, you can configure indents in code style schemes or in .editorconfig files.

Open indentation settings in code style scheme

  1. Click the widget and select Configure Indents for Go.

    EditorConfig menu opened from the Indentation widget
  2. In the dialog that opens, you can change settings for tabs and indents and also configure other code style settings. Click OK.

  3. Reformat the necessary part of your project to apply new indentation settings.

Open indentation settings in .editorconfig

Files in which code style settings are specified via .editorconfig files have the icon in the widget.

  1. Click the widget and select Open .editorconfig.

    The IDE opens the nearest .editorconfig file which affects the file that you're currently working with. To view a list of all available .editorconfig files, click Show Files Related to Project.

  2. Make your changes and reformat the necessary part of your project to apply new indentation settings.

Detect indents automatically

You can configure GoLand to detect the indentation style in the current file and use this style instead of the indents specified in the code style settings for a specific language.

  1. Press Ctrl+Alt+S to open settings and then select Editor | Code Style.

  2. Select the Detect and use existing file indents for editing checkbox.

  3. Apply the changes and close the dialog.

To disable automatic indentation, go back to settings and deselect the checkbox or click the Indentation widget and select Disable Indents Detection for Project.

Last modified: 12 August 2024