Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intellij code formatting, Java annotations on new lines

I'm using IntelliJ 12 and It's putting my member variable annotations on the same line, which i hate! How do I setup the code formatter to keep annotations on separate lines?

thanks!

like image 201
catrapture Avatar asked Mar 08 '13 00:03

catrapture


People also ask

How can I beautify Java code in IntelliJ?

Go to Settings/Preferences | Editor | Code Style, select your programming language, and open the Wrapping and Braces tab. In the Keep when reformatting section, select the formatting rules which you want to ignore and deselect those which should be applied. Reformat your code ( Ctrl+Alt+L ).

How do I format a code automatically in IntelliJ?

If you choose Code | Reformat Code from the main menu or press Ctrl+Alt+L , IntelliJ IDEA tries to reformat the source code of the specified scope automatically.

How do I fix format in IntelliJ?

Sometimes code formatting can get out of sync, but there's an easy fix in IntelliJ IDEA. You can use ⌘⌥L (macOS), or Ctrl+Alt+L (Windows/Linux) to reformat a selection of code according to your reformat settings.


2 Answers

Navigate to Preferences → Editor → Code Style → Java → Wrapping and Braces tab, then locate the section Field annotations and check the option Do not wrap after single annotation.

In IntelliJ v14:

eIntelliJ v14 Java style preferences

like image 129
Daniel Williams Avatar answered Sep 18 '22 05:09

Daniel Williams


In IntelliJ 12 You can find it in setup here (bottom right):

enter image description here

like image 45
Gus Avatar answered Sep 21 '22 05:09

Gus