The IDE uses the astyle C formatting program. It is documented here. You can set your own preferences for this program in a file called formatter.conf. The original version of the file is in your arduino installation's .../lib directory. Once you've modified it the way you like, write your version into the same directory as your preferences.txt (look right at the bottom of the File|Preferences dialog for the pathname to this file).
This is my current version of the formatter.conf file:
# This configuration file contains a selection of the available options provided by the formatting tool "Artistic Style"
# If you wish to change them, don't edit this file.
# Instead, copy it in the same folder of file "preferences.txt" and modify the copy. This way, you won't lose your custom formatter settings when upgrading the IDE
# If you don't know where file preferences.txt is stored, open the IDE, File -> Preferences and you'll find a link
# I added this
# This is standard Arduino IDE
# 2 spaces indentation
# also indent macros
# indent classes, switches (and cases), comments starting at column 1
# put a space around operators
# I would have kept this except that it also pads
# this: f(1,'c') to this f(1, 'c')
# put a space after if/for/while
# if you like one-liners, keep them
I don't know if there are options in astyle to modify the behaviour of what you have shown but dig through the docs and you might be able to fix it up to work the way you like.