Formatting Intellij code, Java annotations on new lines

I use IntelliJ 12 and It puts my member annotation variables on one line, which I hate! How to configure code formatting to save annotations on separate lines?

thank!

+61
java intellij-idea formatting
Mar 08 '13 at 0:58
source share
4 answers

Go to Settings and rarr; Editor -> Code Style -> Java -> Wrapping and Braces , then find the Field Annotations section and check the Do not wrap after a separate annotation option.

In IntelliJ v14:

eIntelliJ v14 Java style preferences

+90
Mar 08 '13 at 1:01
source share

In IntelliJ 12 it can be found here (bottom right):

enter image description here

+19
Mar 08 '13 at 1:02
source share

I think all of the above answers are correct, but here is a step-by-step guide for Mac users:

  • Click "IntelliJ IDEA"
  • Click "Settings"
  • Go to “Code Style” in the left navigation window and you will see “Java” below and click on it!
  • Look at the heading tab "Wrap and brackets" on the right side of the "Settings" window.
  • At this point, you want to find an element called "Do not wrap after a separate annotation" in the "Field Annotations" section. click "OK" and you're done!

enter image description here

+3
May 08 '15 at 17:03
source share

Nothing seemed to me with version 2.3.3 or Android Studio. I gave up and checked the line breaks in the “Hold” section while reformatting. I just have to be very careful when adding line breaks.

enter image description here

0
Aug 11 '17 at 1:51 on
source share



All Articles