Eclipse 是否有换行符
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2846002/
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
Does Eclipse have line-wrap
提问by donpal
I'm editing an XML file with the Eclipse IDE and need to input paragraphs of text. It doesn't seem that eclipse has a line-wrap feature though. Anyone knows if it does or if there's a plugin for that?
我正在使用 Eclipse IDE 编辑 XML 文件,需要输入文本段落。不过,eclipse 似乎没有换行功能。任何人都知道它是否可以,或者是否有插件?
采纳答案by Romain Hippeau
As mentioned in the post by VonC on this same page. Eclipse now has this capability as of 06/2016 Neon.
正如 VonC 在同一页面上的帖子所述。自 06/2016 Neon 起,Eclipse 现在具有此功能。
Try this plugin Eclipse platform plugin
试试这个插件Eclipse 平台插件
It looks like eclipse only has the ability to do it manually on its own and here are the commands. At that point you must reformat the highlighted text manually.
看起来 eclipse 只能自己手动完成,这里是命令。此时,您必须手动重新格式化突出显示的文本。
It's not terribly obvious how to control Eclipse line width and line wrapping in your Java source files. Here's how and where:
如何在 Java 源文件中控制 Eclipse 线宽和换行并不是很明显。以下是方法和地点:
Comment width and line wrapping is set in Preferences->Java->Code Style->Formatter
, then click on the Edit button and select the Comments tab. I like Line Width for Comments to be 120.
注释宽度和换行设置在 中Preferences->Java->Code Style->Formatter
,然后单击“编辑”按钮并选择“注释”选项卡。我喜欢评论的线宽为 120。
Code line wrapping is set nearby, in Preferences->Java->Code Style- >Formatter
, then click on the Edit button and select the Line Wrapping tab. I like a line width of 120 and indent size of 4.
代码换行设置在附近,在 中Preferences->Java->Code Style- >Formatter
,然后单击编辑按钮并选择换行选项卡。我喜欢 120 的线宽和 4 的缩进大小。
Indentation is set separately, in Preferences->Java->Code Style- >Formatter
, then click on the Edit button and select the Indentation tab. I like an indent size of 4, consistent with the Line Wrapping indent setting.
缩进单独设置,在 中Preferences->Java->Code Style- >Formatter
,然后单击“编辑”按钮并选择“缩进”选项卡。我喜欢缩进大小为 4,与 Line Wrapping 缩进设置一致。
As if that's not enough, you can also set printer margins, tab size, etc, in Preferences>General>Editors>Text Editors
where I set the Displayed Tab Width to 4 and Print Margin Column to 120 or more.
好像这还不够,您还可以设置打印机边距、标签大小等,Preferences>General>Editors>Text Editors
其中我将显示标签宽度设置为 4,将打印边距列设置为 120 或更多。
You can also check the Show Print Margin box to get a faint vertical line at the printer margin column
您还可以选中“显示打印边距”框以在打印机边距列中获得一条微弱的垂直线
回答by VonC
Update 2016
2016 年更新
As mentioned by ralfstx's answer, Eclipse 4.6 M4 Neon(or more) has a word-wrap feature!
(Nov 2015, for release mid 2016). In any editor view, type:
正如ralfstx的回答所述,Eclipse 4.6 M4 Neon(或更多)具有自动换行功能!
(2015 年 11 月,2016 年年中发布)。在任何编辑器视图中,键入:
Alt+Shift+Y
Alt+ Shift+Y
(Sadikconfirms in the commentsit works with Eclipse 2019-09)
(Sadik在评论中确认它适用于Eclipse 2019-09)
By default, text editors are opened with word wrap disabled.
This can be changed with the Enable word wrap when opening an editor option on theGeneral > Editors > Text Editors
preference page.
默认情况下,文本编辑器在禁用自动换行的情况下打开。
这可以通过General > Editors > Text Editors
首选项页面上的打开编辑器选项时启用自动换行来更改。
Manually toggle word wrap by clicking in the editor window and pressing (Shift+Alt+Y).
On Mac OS X, press (Cmd-Opt-Y). [Updated May 2017]
通过单击编辑器窗口并按 ( Shift+ Alt+ Y)手动切换自动换行。
在 Mac OS X 上,按 ( Cmd- Opt- Y)。[2017 年 5 月更新]
The famous bug 35779is finally closed by r/#/c/61972/last November.
著名的bug 35779终于在去年 11 月被r/#/c/61972/关闭了。
There are however a few new bugs:
但是有一些新的错误:
- 481873 "No line ruler number repaint on text editing with disabled "quick diff""
- 484142: "Word Wrap makes some actions very slow"
- 488162: "[word wrap] Hide WW preference to avoid unexpected performance impact"
As long as we are unable to provide acceptable editor performance for big files after toggling editor word wrap state on, we should make sure users can't set WW preference 1always on by defaultand wonder why the editors are slow during resizing/zooming.
只要在打开编辑器自动换行状态后我们无法为大文件提供可接受的编辑器性能,我们就应该确保用户不能在默认情况下始终设置 WW 首选项1 ,并想知道为什么编辑器在调整大小/缩放时变慢。
(2020) MarcGuayadds in the comments:
If you want the wrapping to be persistent/automatic, the cdhqpluginseems to still work with the 2019-03 version of Eclipse.
After installing you can turn it on viaWindow->Preferences->Word Wrap
.
如果您希望包装是持久/自动的,cdhq插件似乎仍然适用于 2019-03 版本的 Eclipse。
安装后,您可以通过 将其打开Window->Preferences->Word Wrap
。
Update 2014
2014 年更新
The de.cdhq.eclipse.wordwrapWord-Wrap Eclipse plug-in just got updated, and does provide good wrapping, as illustrated in the project page:
该de.cdhq.eclipse.wordwrap自动换行Eclipse插件刚刚得到更新,并确实提供良好的包裹,如图所示的项目页面:
Original answer May 2010
原始答案 2010 年 5 月
Try the Eclipse Word-Wrap Plug-In here.
在此处尝试 Eclipse Word-Wrap 插件。
Just for the record, while Eclipse Colorermight bring wrapping for xml files, Eclipse has not in general a softwrapping feature for Text editor.
只是为了记录,虽然Eclipse Colorer可能会为 xml 文件带来包装,但Eclipse通常没有用于文本编辑器的软包装功能。
Soft and hard. Soft will just warp the text at the right window border without adding new line numbers (so there are gaps in the list of numbers when you enable them).
软而硬。Soft 只会在右侧窗口边框处扭曲文本,而不会添加新的行号(因此当您启用它们时,数字列表中会有间隙)。
This is one of the most upvoted bugs in Eclipse history: bug 35779(9 years and counting, 200+ votes)
这是 Eclipse 历史上投票率最高的错误之一:错误 35779(9 年和计数,200+ 票)
Update February 2013:
2013 年 2 月更新:
That bug references an old Word wrap plugin, but Oakmentions in his answer(upvoted) a new pluginfor recent (Juno+) versions of Eclipse (so 3.8.x, 4.x, may have been seen working with 3.7)
That plugin is from Florian We?ling, who just updated it (March 2013)
该错误引用了一个旧的自动换行插件,但Oak在他的回答中提到(赞成)一个新的插件,用于最近(Juno+)版本的 Eclipse(因此 3.8.x、4.x,可能已经看到与 3.7 一起使用)
该插件是来自Florian We?ling,刚刚更新了它(2013 年 3 月)
Right click in an opened file and select "Toggle Word Wrap" (shortcut ctrl+alt+e)
右键单击打开的文件并选择“切换自动换行”(快捷键ctrl+ alt+ e)
回答by jfritz42
Ctrl+Shift+Fwill format a file in Eclipse, breaking long lines into multiple lines and nicely word-wrapping comments. You can also highlight just a section of text and format that.
Ctrl+ Shift+F将格式化Eclipse的一个文件,打破长行成多行,并很好地自动换意见。您还可以仅突出显示一部分文本并设置其格式。
I realize this is not an automatic soft/hard word wrap like the other answers, but I don't think the question was asking for anything fancy.
我意识到这不是像其他答案一样的自动软/硬自动换行,但我不认为这个问题要求任何花哨的东西。
回答by ralfstx
Eclipse Neon(4.6), release date June 2016, includesword wrap for text editors. It's disabled by default, and can be activated and deactivated using the key shortcut Alt+Shift+Y
(on Mac OS, Cmd-Opt-Y
). Some editors also supply a tool bar button for activating word wrap.
Eclipse Neon(4.6),发布日期 2016 年 6 月,包括用于文本编辑器的自动换行。默认情况下它是禁用的,可以使用快捷键激活和停用Alt+Shift+Y
(在 Mac OS 上,Cmd-Opt-Y
)。一些编辑器还提供了用于激活自动换行的工具栏按钮。
See the 4.6 M4 New and Noteworthy
回答by Romain
The Eclipse Word-Wrapplugin works for any type of file for me.
在Eclipse的自动换行的插件作品对我来说任何类型的文件。
回答by Oak
Ahti Kitsik's plugin is mentioned above, but there's a newer pluginby another author that works with newer versions of Eclipse (up to Juno, at least), and also fixed the line numbering issue in the older plugin.
上面提到了 Ahti Kitsik 的插件,但另一位作者的新插件可以与较新版本的 Eclipse(至少到 Juno)一起使用,并且还修复了旧插件中的行号问题。
Full installation instructions are at Eclipse version to download the word wrap plug-in
完整安装说明在Eclipse版本下载自动换行插件
回答by pba
From Bug 35779 - Comment 187:
A workaround, that I use for the last years now, is to use the eclipse wiki markup editor for editing text files. This supports word wrap, and this is enough for me. Maybe this information could be of help to some of you.
我在过去几年中使用的一种解决方法是使用 eclipse wiki 标记编辑器来编辑文本文件。这支持自动换行,这对我来说已经足够了。也许这些信息可能对你们中的一些人有所帮助。
回答by mannadu
Word wrap comes out of the box with Juno now. Right Click on the editor and select the "Word Wrap" option from the dropdown.
现在,自动换行与 Juno 一起开箱即用。右键单击编辑器并从下拉列表中选择“ Word Wrap”选项。
回答by RandyMorris
回答by Nicolas
In Eclipse v4.7 (Oxygen):
在 Eclipse v4.7(氧气)中:
Window menu → Editor → Toggle Word Wrap (Shift+Alt+Y)