IntelliJ IDEA 14.0.0 Web Help

Configuring Autofolding Behavior

IntelliJ IDEA allows displaying source code in a folded form, making it really concise, and hiding from view the details you might consider less important. When a file is first opened for editing, certain code constructs can be shown folded. It is up to you to define the desired set of code constructs to be folded by default. When you hover your mouse pointer over the collapsed code fragment, its preview is displayed in a pop-up window.

IntelliJ IDEA can also fold lines in consoles. This lets you hide extraneous information and make console output easier to read and comprehend.

To configure autofolding behavior in the editor

  1. Open Settings.
  2. Under the Editor node, click Code Folding. Code Folding page is displayed.
  3. In the Collapse by default list, select the check boxes to the left of the code constructs you want to be displayed collapsed.
  4. Apply changes.

Now, when you first open files for editing, the selected code constructs will be shown as shaded brief information, with the preview available at the mouse pointer.

For example, you can automatically hide imports:

foldingAuto.png

I18N support is enhanced with the special folding that allows you to hide method calls, retrieving properties from resource bundles and replace them with actual property values:

foldingAutoI18n.png

Anonymous classes can be presented in a concise way, as shown below:

codeFoldingClosure.png

To configure autofolding behavior in consoles

  1. Open the IDE Settings and click Console Folding. The Console Folding page is displayed.
  2. In the Fold console lines that contain area, configure a list of patterns that determine the lines to be always folded in console output. Use add (Alt+Insert), edit1 (Enter) or delete (Alt+Delete) to create, edit or remove the patterns.
  3. In the Exceptions area, configure a list of patterns that determine the lines that never should be folded in console output. Use add (Alt+Insert), edit1 (Enter) or delete (Alt+Delete) to create, edit or remove the patterns.

To add a specific console output line to the list of folding patterns

  1. In the console output, select the relevant line.
  2. On the context menu, choose Fold lines like this.
  3. In the Console Folding dialog box that opens, the selected line is added to the Fold console lines that contain list. Click OK to have the line added to the list as is. To edit the new pattern, select it, click edit1 (Enter), and update the character string as necessary in the Folding Pattern dialog box that opens.

See Also

Last modified: 4 December 2014
comments powered by Disqus