How do I modify Eclipse code formatting?

后端 未结 5 694
醉酒成梦
醉酒成梦 2020-12-01 09:30

When I reformat code with Eclipse, it turns method headers like this:

public void myMethod(String param) {

into method headers like this:

相关标签:
5条回答
  • 2020-12-01 09:50

    Have a look at Window>Preferences>Java>Code Style>Formatter.

    There you can configure almost everything. Your case is found at

    Line Wrapping>Method Declarations>Parameters.

    0 讨论(0)
  • 2020-12-01 09:52

    Go into preferences: Java -> Code Style -> Formatter

    Restore Defaults or edit what's there.

    Additionally, Code Style -> Code Templates will allow you to define generate code formatting.

    Note that this is for Eclipse Workspace as a whole, the same Preferences can be accessed under the project preferences if you want to get more fine grained at a per project level.

    0 讨论(0)
  • 2020-12-01 09:59

    In my version of Eclipse, I found the option under Window->Preferences->Java->Code Style->Formatter, then clicked the Edit.. button.

    In the new window, go to the Line Wrapping tab and find Method Declarations. You want to change the Line wrapping policy. The Force split check box seems to do the same.

    0 讨论(0)
  • 2020-12-01 10:07

    In eclipse you can define your code formatting use Code Style ,

    for MAC System :--> Eclipse --> Preference -- > java--> code Style

    for Window System :--> Window->Preferences->Java->Code Style->Formatter

    0 讨论(0)
  • 2020-12-01 10:07

    The best way to change your format is to go to Window-> Preferences-> Java-> Code Style-> Formatter. Inside the formatter window, eclipse has a couple of built in styles, but the best way is create a new profile of your own by pressing on New. You can change the format as you please on the edit tab

    As shown in the image

    You can change parentheses and curly braces positioning along with other stuff.

    0 讨论(0)
提交回复
热议问题