GoLand 2024.2 Help

Code Folding

Use this page to specify the default code folding settings. For shortcuts on how to expand or collapse code elements, refer to the code folding section.

Item

Description

Show code folding arrows

Display code folding icons in the editor.

From the list, select the way in which the icons for unfolded areas should be displayed:

  • Always: code folding icons are always displayed in the gutter.

  • On mouse hover: code folding icons appear only when you hover over the gutter.

Code folding

Show bottom arrows: display the bottom folding arrows in the gutter as well. Otherwise, only the top arrows are shown.

Fold by default

Select the code fragments that should be folded by default, that is, when a file is first opened in the editor.

Fold by Default section

In this section, choose the language-specific elements that should be folded by default when you open a file of the corresponding type.

General

Option

Unfolded code

Folded code

Imports

Folds the import section.

Code folding options: Imports
Code folding options: Imports

Documentation comments

Folds multiline comments.

Code folding options: Documentation comments
Code folding options: Documentation comments

Method bodies

Folds code in methods.

Code folding options: Method bodies
Code folding options: Method bodies

Custom folding regions

Folds regions that are marked with editor-fold or region comments.

For more information, refer to Use the Surround With action.

Code folding options: Custom folding regions
Code folding options: Custom folding regions

Go

Option

Unfolded code

Folded code

One-line 'if' blocks with a single 'return'

You can select a style of how you want to fold single-line return statements. You can select between two styles: if err != nil { return err } and if err != nil : err ⤴.

Code folding options: Single-line return statements
Code folding options: Single-line return statements

One-line 'if' blocks with a single 'panic'

You can select a style of how you want to fold single-line panic statements. You can select between two styles: if err != nil { panic("error") } and if err != nil : "err" ⤴.

Code folding options: Single-line panic statements
Code folding options: Single-line panic statements

One-line 'if' blocks for error handling

Fold blocks that handle error and consist of a single line.

Code folding options: Single-line error handling blocks
Code folding options: Single-line error handling blocks

One-line functions with a single 'return'

Code folding options: Single-line return functions
Code folding options: Single-line return functions

One-line case clauses

Code folding options: Single-line error handling case clauses
Code folding options: Single-line error handling case clauses

Formatted strings

Code folding options: Format strings
Code folding options: Format strings

JavaScript

Option

Unfolded code

Folded code

One-line functions in JavaScript and TypeScript

One-line functions in JavaScript and TypeScript⋖
One-line functions in JavaScript and TypeScript⋖

Object literals

Object literals
Object literals

Array literals

Array literals
Array literals

XML literals

XML literals
XML literals

SQL

Option

Unfolded code

Folded code

Put underscores inside numeric literals (6-digit or longer)

Put underscores inside numeric literals (6-digit or longer)
Put underscores inside numeric literals (6-digit or longer)

XML

Option

Unfolded code

Folded code

XML Tags

XML Tags
XML Tags

HTML 'style' attribute

HTML 'style' attribute
HTML 'style' attribute

XML entities

XML entities
XML entities

Data URIs

<img src="data:image/png; base64, 2P4//8/w38gljNBAAO9TXL0Y4O"/>
<img src="data:"/>
Last modified: 11 October 2024