如何防止 Eclipse 在 XML 和 HTML 文件中换行?
是否可以完全阻止 Eclipse 对 XML 和 HTML 文件进行换行?对于 java 文件来说很容易做到这一点,但我找不到 XML 和 HTML 文件的类似设置。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
是否可以完全阻止 Eclipse 对 XML 和 HTML 文件进行换行?对于 java 文件来说很容易做到这一点,但我找不到 XML 和 HTML 文件的类似设置。
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(3)
首选项> XML> XML 文件 >编辑器
,并在那里设置line-width
(在
Web > HTML 文件
下对 HTML 进行相应操作)Preferences > XML > XML Files > Editor
, and setline-width
there(Do accordingly for HTML, under
Web > HTML files
)是的,XML 格式设置位于 IDE 范围的首选项选项卡中,显然不能针对每个项目进行设置。
我想指出的是,真正令人烦恼的是元素之间的“自由文本”包装,例如:
这在处理模式时确实很不方便例如,logback.xml 文件中的格式。
我刚刚发现,如果我将文本括在
之间,Eclipse 不会格式化该位。
例如:
只是想分享一下。
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.
注意:自 2003 年以来,Eclipse 中的单词/换行是一个“痛苦”的话题,因为这个话题被大量投票 bug 35779
正如 Bozho 提到的,只有 < a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=35779#c16" rel="nofollow noreferrer">硬包装(指定长度)
替代文本 http://www.openengsb.org/images/codingstyle/eclipse-xml- settings.png
提醒:
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: