Howto prevent eclipse from line wrapping in XML an

2019-01-25 02:24发布

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.

3条回答
姐就是有狂的资本
2楼-- · 2019-01-25 02:58

Preferences > XML > XML Files > Editor, and set line-width there (Do accordingly for HTML, under Web > HTML files)

查看更多
The star\"
3楼-- · 2019-01-25 03:02

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.

查看更多
Bombasti
4楼-- · 2019-01-25 03:13

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.

查看更多
登录 后发表回答