Search code examples
jetbrains-ideparenthesescurly-braces

Jetbrains IDE'S putting the closing curly braces or parenthesis automatically


Sometimes, we put our bare "if" statements into the code without adding the curly braces if it is composed of only one expression. Unlike Sublime Code Completer, it is a hassle to put the enclosing parenthesis or curly braces around my statements in the Jetbrains Products. I mean

if (something)
   statement

when I pressed to "{", I want for ide to put the enclosing one at the end of the statement instead of putting adjacent to the newly put opening one.

Not like this:

if (something) {}
   statement

Intended form:

if (something){
   statement
}

Is there a way to configure as wanted?


Solution

  • As far as I know, there is not a way to enclose a code block exactly the way you are looking for, but there is a similar feature available without too much more work. If you simply select the code you would like to wrap and enter an opening bracket, IntelliJ will wrap your code in the brackets and place both the brackets on their proper line given your coding style.