如何防止 Eclipse 在 XML 和 HTML 文件中换行?

发布于 2024-08-17 00:44:43 字数 90 浏览 2 评论 0 原文

是否可以完全阻止 Eclipse 对 XML 和 HTML 文件进行换行?对于 java 文件来说很容易做到这一点,但我找不到 XML 和 HTML 文件的类似设置。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

浅浅 2024-08-24 00:44:43

首选项> XML> XML 文件 >编辑器,并在那里设置line-width
(在 Web > HTML 文件 下对 HTML 进行相应操作)

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

黯然 2024-08-24 00:44:43

是的,XML 格式设置位于 IDE 范围的首选项选项卡中,显然不能针对每个项目进行设置。

我想指出的是,真正令人烦恼的是元素之间的“自由文本”包装,例如:

some free text

这在处理模式时确实很不方便例如,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.

追风人 2024-08-24 00:44:43

注意:自 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

提醒:

  • Soft 只会使右侧的文本变形
    窗口边框而不添加新的行号(因此列表中存在间隙
    启用它们时的数字)。
    此模式对于 HTML 等很有用。
    软包装的一个很好的功能是自动压痕:如果有
    行首有空格,自动换行
    缩进相同的量。

  • 会在您键入时在文本中添加和删除换行符以平衡宽度。
    在这里,您通常可以设置边距(例如 80 个字符)。
    这对于自述文件和其他将在终端中阅读的内容很有用。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文