当我使用 Eclipse 重新格式化代码时,它会将这样的方法标头: 变成
public void myMethod(String param) {
这样的方法标头:
public void myMethod(
String param) {
当我来到这里时,我以前从未使用过 Eclipse,并且导入了其他人提供的项目设置。我发现在我工作过的小型新项目中 Eclipse 并没有这样做,所以它必须在我导入的设置中。但我已经检查了我能找到的每个面板,以及我可以在工作区中找到的每个隐藏文件,但我无法弄清楚是什么导致了这种情况。
我该如何关闭它?我不想在我的方法签名中的参数之前有换行符,我无法想象为什么有人会这样做!
When I reformat code with Eclipse, it turns method headers like this:
public void myMethod(String param) {
into method headers like this:
public void myMethod(
String param) {
When I was brought on here I'd never used Eclipse before, and I imported project settings provided by someone else. I have seen that on small new projects I've worked on Eclipse does not do this, so it must be in the settings I've imported. But I've gone through every panel I can find, as well as every hidden file I can find in the workspace, and I can't figure out what is causing this.
How do I turn it off? I don't want a newline before parameters in my method signatures, and I can't imagine why anyone would!
发布评论
评论(5)
查看窗口>首选项>Java>代码样式>格式化程序< /kbd>。
在那里您可以配置几乎所有内容。 中找到。
您的案例可以在换行>方法声明>参数
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.
在我的 Eclipse 版本中,我在 Window->Preferences->Java->Code Style< 下找到了该选项/kbd>->格式化程序,然后单击编辑..按钮。
在新窗口中,转到换行选项卡并找到方法声明。您想要更改换行策略。 强制拆分复选框似乎具有相同的作用。
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.
进入首选项:Java -> 代码风格 -> 格式化程序
恢复默认值或编辑其中的内容。
此外,代码风格 -> 代码模板将允许您定义生成代码格式。
请注意,这适用于整个 Eclipse Workspace,如果您想在每个项目级别获得更细粒度的信息,可以在项目首选项下访问相同的 首选项。
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.
在 Eclipse 中,您可以使用 Code Style 定义代码格式,
对于 MAC 系统:--> Eclipse --> 偏好 --> java--> 窗口系统的代码样式
:--> 窗口->首选项->Java->代码样式->格式化程序< /kbd>
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
更改格式的最佳方法是转到“窗口”->“首选项-> Java->代码风格->格式化程序。在格式化程序窗口中,Eclipse 有一些内置样式,但最好的方法是按“新建”创建您自己的新配置文件。您可以在编辑选项卡上随意更改格式
您可以更改括号和花括号的位置与其他东西。
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
You can change parentheses and curly braces positioning along with other stuff.