Ing*_*gel 3 xml reformat intellij-idea
我想阻止IDEA在某些元素周围插入换行符,类似于HTML格式,其中某些元素(如<b>)保持内联.
我有一个带有DTD的XML方言,它声明了混合内容.
DTD:
<!ELEMENT mixed (#PCDATA|inline)*>
<!ELEMENT inline #PCDATA>
Run Code Online (Sandbox Code Playgroud)
XML文件:
<mixed>
Some text with <inline>inline elements</inline>
and a line break.
</mixed>
Run Code Online (Sandbox Code Playgroud)
当我重新格式化XML文件时,IDEA会将其转换为
<mixed>
Some text with
<inline>inline elements</inline>
and a line break.
</mixed>
Run Code Online (Sandbox Code Playgroud)
我查看了Code style-> XML-> Other的所有选项."保留空白"选项限制性太强,因为我希望IDEA打破长线.
在IDEA 13中,您可以使用新的Formatter Control功能来禁用所选代码行的自动形式.要启用此功能,您应在项目设置中标记以下复选框:

然后在注释中插入选定的标记,以划分不应由重新格式化代码工具格式化的代码片段,例如:
<root>
<!-- @formatter:off -->
<mixed>
Some text with <inline>inline elements</inline>
and a line break.
</mixed>
<!-- @formatter:on -->
<mixed>
Some text with
<inline>inline elements</inline>
and a line break.
</mixed>
</root>
Run Code Online (Sandbox Code Playgroud)
不幸的是,在以前版本的IDEA中没有这样的功能,在这种情况下,我唯一知道的选项是手动格式化代码而不使用重新格式化代码工具.
| 归档时间: |
|
| 查看次数: |
1251 次 |
| 最近记录: |