Is it possible to completely stop Eclipse from line wrapping XML and HTML files? It is easy to do this i.e. for java files, but I couldn't find similar settings for XML and HTML files.
问题:
回答1:
Note: the word/line wrapping in eclipse is a "sore" topic, since 2003, as this massively voted bug 35779
As Bozho mentions, there is only hard-wrapping (at a specify length)
alt text http://www.openengsb.org/images/codingstyle/eclipse-xml-settings.png
Reminder:
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).
This mode is useful for HTML and the like.
A nice feature of the soft wrap is automatic indentation: If there is whitespace at the beginning of the line, the wrapped lines are automatically indented by the same amount.Hard will add and remove newlines in the text as you type to balance the width.
Here, you can usually set a margin (80 characters, for example).
This is useful for READMEs and other stuff that will be read in a terminal.
回答2:
Preferences > XML > XML Files > Editor
, and set line-width
there
(Do accordingly for HTML, under Web > HTML files
)
回答3:
Yes, the settings for XML formatting are in the IDE-wide preferences tab and apparently they cannot be set on a per-project basis.
I want to point out that what is really annoying is the wrapping of "free text" between elements like in:
<element>some free text</element>
That's really an inconvenience when dealing with the pattern format in logback.xml files, for instance.
I just found out that Eclipse won't format that bit if I enclose the text between <![CDATA[..]]>
.
For instance:
<pattern><![CDATA[%d{HH:mm:ss.SSS} [%thread] [%X{host}|%X{ip}|%X{user}] %-5level %logger{36} - %msg%n]]></pattern>
Just wanted to share that.