How to stop Eclipse from splitting annotations on new lines

@Setter @Getter private String query; 

I get something like this after formatting, how to prevent it and keep my annotations in one line? I did not find any useful setting inside the Formater configuration.

 @Setter @Getter @sthElse @oneMore @etc private String query; 

This is how I would like to be

+7
source share
3 answers

One hack that allows you to force a new line whenever you want is to add a comment to the line ( // ) at the end of the line. For example, when I have parameter annotations, I want them to line up like this:

 public ModelView finish(// @PathParam("stampId")// long stampId, // 

Instead of this:

 public ModelView finish(@PathParam("stampId") long stampId, 

My use of // gives me finer control over this. Therefore, if you change the "Insert new lines after annotations" that you should get:

 @Setter @Getter @sthElse @oneMore @etc // private String query; 

I am sure that if I had a look at the Eclipse formatting code, I could add it there, but I don’t have time for that. :-)

+6
source

IMHO, the closest you can get:

 @Setter @Getter @sthElse @oneMore @etc private String query; 

(via Formatter-> New Lines-> Insert new lines after annotations using the method

+8
source

When you edit your formatting profile, go to the New Lines tab. There's a group labeled "Annotations" on this preferences page. You should be able to undo the settings for "Insert a new line after annotations on elements / parameters / local variables"

+1
source

All Articles