nz_21
nz_21

Reputation: 7343

intellij wrapping brackets around if-else

Coming from a language like python, I often forget to wrap parenthesis around if conditions when writing Java.

Is there a parenthesis completer built into IntelliJ? If not, how do I best work around this issue? (short of manually wrapping with parenthesis myself -:))

Upvotes: 0

Views: 338

Answers (1)

Rumid
Rumid

Reputation: 1709

  1. When you will start typing if code completion will ocurs. Push enter - your carret will land inside bracket.
  2. Use surrounding blocks of code. You can first write boolean condition then press shortcut for Surround With option (on windows/linux by default it is Ctrl + Alt + T) and choose if(expr). Or if you want to only surround with paranthesis, then use (Surround With) and then choose (Curly Braces).
  3. You can use predefined live template with ifn which will initialize if block with comparison to null. You can also configure your own template.

Also you might want to check if this option is selected in your IDE:
Settings(Preferences) | Editor | General | Smart Keys, Surround selection on typing quote or brace

Upvotes: 1

Related Questions