Pergunta

Currently my eclipse follows this code format:

public class TempClass {
    public static void main(String[] args) {
    }

}

So when I select all code and press  Ctrl  +   Shift    +  F , it formatts the code in above style.

Is there any way I can set my default code format to this:

public class TempClass 
{
    public static void main(String[] args) 
    {
    }
}
Foi útil?

Solução

Follow this:

Window -> Preferences -> Java -> Code Style -> Formatter -> [Edit...] -> Braces

There you can configure it!

Outras dicas

Right click on project->java -> code Style->Formatter->Configure Workspace Settings..(link on top right)>Select Active Profile->Edit->Braces(Tab)

Look for Brace Position:

You can change the brace position, for eg) constructor declaration to next line

You can create a new profile as well if you want(instead of using the Eclipse Built-in]

enter image description here

Change the sample code.

and Apply changes.

Version:Helios Service Release 2

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top