IntelliJ IDEA 2016.3 Help

Completing Statements

On this page:

Completing statements

The Smart Enter completion enables you to create syntactically correct code constructs.

To automatically complete a statement, follow these steps:

  • Start typing a statement, and press Ctrl+Shift+Enter.

    The punctuation required in the current context is added and the caret moves to the next editing position.

Examples

Completing a method declaration

Start typing a method declaration, and press Ctrl+Shift+Enter after the opening parenthesis:

completePunctuation1.png

This will create the entire construct of a method, the caret resting inside the method body:

completePunctuation2.png

Completing code constructs

Start typing a code construct:

completePunctuation3.png

After pressing Ctrl+Shift+Enter, the construct is completed, and the caret is placed at the next editing position:

completePunctuation4.png

Automatic encapsulation

IntelliJ IDEA automatically encapsulates a method call, when you directly type a new method call next to it. For example, consider the following code:

|"test"

Note the caret that rests just before the opening quote. Then type the method call.

When println gets the focus in the suggestion list, select it with Ctrl+Shift+Enter.

System.out.println("test");
/help/img/idea/2016.3/autoEncapsulation.png

See Also

```

Reference:

Last modified: 21 March 2017