Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse formatter: can it ignore annotations?

Sometimes I want annotations on fields be in a single line and sometimes in a line each. Is there any way to make Eclipse formatter just ignore these annotations and leave the lines breaks just as I did?

like image 261
sinuhepop Avatar asked Mar 21 '12 11:03

sinuhepop


People also ask

How do I use code formatter in Eclipse?

Go to Source | Format Document or press Ctrl+Shift+F.

What is @formatter off?

Eclipse 3.6 allows you to turn off formatting by placing a special comment, like // @formatter:off ... // @formatter:on. The on/off features have to be turned "on" in Eclipse preferences: Java > Code Style > Formatter . Click on Edit , Off/On Tags , enable Enable Off/On tags .


1 Answers

Not quite sure what you mean, but you break up lines for field this way:

String text = 
"cake" +
"more cake" +
"alot more cake";

This is also an option: You can go to Properties -> Java code style -> Formatter -> Edit: Then there should be some tags to on/off. Also include this line in your code:

/* @formatter:on */
like image 86
McBoman Avatar answered Sep 20 '22 20:09

McBoman