IntelliJ IDEA 2021.1 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.

ItemDescription
Show code folding outlineSelect this checkbox if you want the code folding toggles to be shown in the editor. Clear the checkbox to hide the toggles.
Fold by default

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

  • File header

  • Imports

  • Documentation comments

  • Method bodies

  • Custom folding regions- blocks of code within matched pairs of curly braces {}, learn more from Expand or collapse code elements.

    For example, select a block of code for which you want to create a folding region, press Ctrl+Alt+T, select either <editor fold> or region...endregion comments depending on the style you need, and name the created custorm region. Now, when you select the Custom folding regions option, IntelliJ IDEA will fold such regions when you open your file in the editor.

    Custom region
    Folded custom region
  • Android- language-specific code fragments in Android

  • JavaScript- language-specific code fragments in JavaScript and TypeScript

  • Java -language-specific code fragments in Java

  • Properties- code in .properties files

    Use the Fold '{0}','{1}' ... placeholders to corresponding context expressions from Java/Kotlin code option to show folded substitutions for property key values. Note that using these settings might potentially slow down the .properties file loading.

  • SQL- language-specific code fragments in SQL

  • Scala- language-specific code fragments in Scala

  • XML- language-specific code fragments in XML

Last modified: 14 May 2021