Create foreach loop automatically inserts newline


I might just be doing this wrong, but I let intelij generate a foreach loop for me, either by using Ctrl + j or by just typing "for" and the menu comes up. I select the foreach option and press Enter and I get a foreach loop with an extra newline in the middle, like

It does that when I use Tab instead of Enter as well.

What am I doing wrong here?

Thank you.


Please check your code style settings:


Hi, thanks for answering. I've tried messing around with the style settings for a for() where you showed me but for some reason it keeps that behavior.


Does it happen with the default code style scheme? Try with all the defaults after removing IDE config/plugins folders (, make a backup first so that you can restore these folders if it doesn't help.


I also have this same issue, its not related to code style, as theres no even a block to manage for each loops.. keeping default it still is messed up. thanks.


Report an issue with the steps to reproduce and a sample project (with your code style embedded) at

Also attach the logs (


Please sign in to leave a comment.