Java coding style in Eclipse

For each method, I want to add a space between the method name and the right brace. For instance,

public void setName(String name) { } 

I want a space between them) and {. Is it possible to automatically install this in Eclipse or somewhere? It is annoying to add this space every time.

+5
source share
4 answers

The default code style will add the space you want and it can be automatically formatted every time you save:

Window-> Settings-> Java-> Editor-> SaveActions: check the box "Source format code"

If you want to change some default styles, you can do this if you go to formatting and edit the active profile:

Save action

+2
source

in the eclipse menu → Windows → settings, search for formatting, then edit and check the box: insert a space before opening the bracket

enter image description here


enter image description here

+5
source

See the eclipse manual:

http://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.cdt.doc.user%2Ftasks%2Fcdt_t_add_codetemp.htm

These are commonly called “coding patterns” for future references in any IDE.

+1
source

There are various coding patterns that you can use that will change the formatting of your code to the specified specifications. But even without a special template, the default template adds a space, you just need to automatically format your code.

On Windows : Ctrl + Shift + F

On Mac : + + F

It will format your code and automatically add a space.

+1
source

All Articles