automatic new lines and tabs when making if/for/while etc.

Answered

When I make an if statement such as "if () {" and I click enter after I type the opening brace then I get a new line with a closing brace. Is it possible to configure intellij, so that once I click enter on the opening brace, it will automatically complete the brace and add a new line that is already indented in between.

 

Ex. I type "if() {" and click enter

Currently I get:

"if() {

}" 

Can I configure intellij so that I get:

"if() {

 

}" and there is already an indent in that empty line.

0
6 comments

Hello,

Have you tried to set "Next Line" for "Braces Placement - Other" in "Settings/Preferences | Editor | Code Style | Java"?

0
Avatar
Permanently deleted user

I have tried that, but, honestly, I don't think any of the settings changes I have made have actually changed the settings when I type.

0

Could you please attach your exported Code Style settings? I've got new line added on my side.

0
Avatar
Permanently deleted user

<code_scheme name="Project" version="173">
<codeStyleSettings language="JAVA">
<option name="BRACE_STYLE" value="2" />
</codeStyleSettings>
</code_scheme>

 

Another thing I have noticed is that it works with my older projects, but it is not working with any new projects I have made yesterday and today.

But when I import the preferences from my old project to my new project it still doesn't work.

0
Avatar
Permanently deleted user

I started doing some problems without changing anything. And after I renamed it and refracted it started to magically work again. So I guess my problem was magically resolved.

0

Nice to hear that it works. Feel free to contact us if you face the issue again.

0

Please sign in to leave a comment.