IntelliJ - 有"重新格式化代码"删除文本中不必要的HTML换行符?

时间:2017-01-21 00:27:55

标签: html intellij-idea pycharm jetbrains-ide

使用"重新格式化代码"在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>

我查看了重新格式化代码的设置,但没看到如何执行此操作。可能是其中一个&#34; Keep newlines&#34;选项,但删除它们似乎也删除标签之间的换行符。有没有办法做到这一点?

1 个答案:

答案 0 :(得分:1)

是的,Intellij有代码样式选项,名为&#39;保留文字中的换行符&#39;对于HTML。禁用该选项,然后重新格式化代码。

enter image description here