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?
            Asked
            
        
        
            Active
            
        
            Viewed 1,995 times
        
    10
            
            
        - 
                    This question was answered here: http://stackoverflow.com/questions/1820908/how-to-turn-off-the-eclipse-code-formatter-for-certain-sections-of-java-code http://stackoverflow.com/questions/352599/how-can-i-make-eclipses-autoformatter-ignore-a-section-of-code – Gabriel Rodriguez Jun 13 '13 at 17:23
2 Answers
1
            
            
        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 */
0
            
            
        I think so. In Preferences go to Java - Code Style - Wrapper. Then edit your active profile, click "Line Wrapping" and then "Annotations - Element-value pairs". Then set the Line wrapping policy to "Do not wrap".
 
    
    
        Friek
        
- 1,533
- 11
- 13
- 
                    2That will not do it... It will just leave all annotation on a single line - no matter how many there are :-) – Tonny Madsen Mar 21 '12 at 12:33
- 
                    Indeed, you're right. In that case, I don't think the formatter can ignore annotations.. – Friek Mar 21 '12 at 12:36
- 
                    I am having to use eclipse in a new project and its things like this that drive me crazy. I set my save actions (which is a great feature of eclipse) but now it screws up all the annotation formatting. I have no perfect solution yet but a partial solution is to change the save actions to only format the changed lines. Its a part way solution – Shawn Vader Oct 31 '13 at 10:58
