Java 如何在日食中关闭断线

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3242360/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 17:42:17  来源:igfitidea点击:

how to turn off break line in eclipse

javaeclipse

提问by ant

Does anybody know how to turn line breaking in eclipse after you press CTRL + SHIFT + F(code format), ex :

有没有人知道如何在按下CTRL + SHIFT + F(代码格式)后在 Eclipse 中打开换行符,例如:

System.err
                    .println("Incorrect file name, make sure you include .extension with your file name");

采纳答案by draganstankovic

Go to Window->Preferences->Java->Code Style->Formatter. Create new formatter. Click on edit and then pick tab Line Wrapping and set Line Wrapping policy to Do not wrap.

转到窗口->首选项->Java->代码样式->格式化程序。创建新的格式化程序。单击编辑,然后选择选项卡换行并将换行策略设置为不换行。

回答by soru

In Helios, set 'Line Wrapping/Function Call/Indentation Policy' to 'Indent on Column' for all cases. This seems to stop the pathological case where it splits a line to try and fit within a fixed width but ends up with it further to the right than it would have been unsplit.

在 Helios 中,将所有情况的“换行/函数调用/缩进策略”设置为“列缩进”。这似乎阻止了病态的情况,它拆分一条线以尝试在固定宽度内拟合,但最终它比未拆分的更靠右。

Or, as suggested above, disable line wrapping, or set a very wide line width. But I find it better to have it wrap and get it right than not to wrap at all.

或者,如上所述,禁用换行,或设置非常宽的线宽。但我发现把它包裹起来并做好它比根本不包裹更好。

回答by Oliver Pearmain

The default line wrapping in Eclipse is really rather irritating and the main reason why is that the 'line width' is set as 80 characters, clearly a hangover from the nineteen eighties. This really should be updated now that everyone uses high resolution monitors instead of 80 char wide punch cards.

Eclipse 中的默认换行确实很烦人,主要原因是“行宽”设置为 80 个字符,这显然是 19 世纪 80 年代的遗留问题。现在确实应该更新,因为每个人都使用高分辨率显示器而不是 80 个字符宽的穿孔卡片。

You probably don't want to turn it off entirely but instead you want to change the 'line width' to something more sensible (otherwise when you use the auto formatter you may get lines of code that go on forever).

您可能不想完全关闭它,而是想将“线宽”更改为更合理的值(否则,当您使用自动格式化程序时,您可能会得到永远运行的代码行)。

I would suggest a value of 140, which seems to work nicely for most of us now using 1080p monitors.

我建议使用 140 的值,这对于我们现在使用 1080p 显示器的大多数人来说似乎很好用。

In order to do this you need to...

为此,您需要...



With-in Preferences, navigate to...

With-in Preferences,导航到...

> Java
    > Code Style
        > Formatter

You can't edit the default profiles so you have to hit New...and type a name like 'Eclipse 140 Line Width' for your profile and OK.

您无法编辑默认配置文件,因此您必须为您的配置文件点击New...并键入一个名称,例如“Eclipse 140 Line Width”和OK.

Then Editthe profile

然后Edit是个人资料

Change to the Line Wrappingtab

切换到Line Wrapping选项卡

Change the Maximum Line widthfrom 80 to 140.

Maximum Line width80更改为140

Then OKyour way out.

然后OK你的出路。



If you then want to fix up your existing code, select your target code and use the Source > Formatmenu option.

如果您想修复现有代码,请选择目标代码并使用Source > Format菜单选项。

回答by Sancho George

There is an option "never join wrapped lines". This will help to keep our custom wrapping unchanged. Great Feature.

有一个选项“从不加入包装线”。这将有助于保持我们的自定义包装不变。很棒的功能。