【问题标题】:IntelliJ - Have "Reformat Code" remove unnecessary HTML newlines in text?IntelliJ - “重新格式化代码”是否删除了文本中不必要的 HTML 换行符?
【发布时间】:2017-06-06 01:57:26
【问题描述】:

在 HTML 文件上使用 IntelliJ(和其他 JetBrains IDE)中的“重新格式化代码”将在文本中添加换行符,以确保文本不会超出右边距。我正在寻找的是能够将部分文本移回上一行,如果上一行有空间的话。

例如,如果我原来有:

<p>
    This is some text that is fairly long and won't fit on a single line without going over the right margin.
</p>

重新格式化代码会产生类似的结果(假设右边距非常小):

<p>
    This is some text that is fairly long and
    won't fit on a single line without going
    over the right margin.
</p>

但是如果我删除一些文本:

<p>
    This is some text that
    won't fit on a single line without going
    over the right margin.
</p>

我想重新格式化代码以自动生成:

<p>
    This is some text that won't fit on a
    single line without going over the right
    margin.
</p>

我查看了重新格式化代码的设置,但没有看到如何执行此操作。可能是“保留换行符”选项之一,但删除这些选项似乎也会删除标签之间的换行符。有没有办法做到这一点?

【问题讨论】:

    标签: html intellij-idea pycharm jetbrains-ide


    【解决方案1】:

    是的,Intellij 为 HTML 提供了名为“在文本中保留换行符”的代码样式选项。禁用该选项,然后重新格式化代码。

    【讨论】:

      猜你喜欢
      • 2023-03-27
      • 1970-01-01
      • 2023-03-09
      • 1970-01-01
      • 1970-01-01
      • 2018-06-22
      • 2011-01-01
      • 1970-01-01
      • 2015-10-01
      相关资源
      最近更新 更多