Eclipse html:不缩进某些标签
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4606519/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Eclipse html: Doesn't indent on some tags
提问by stolsvik
For some reason, Eclipse seems to think that e.g. <div>
and <td>
tags aren't indenting-worthy.
出于某种原因,Eclipse 似乎认为 eg<div>
和<td>
标签不值得缩进。
Ctrl+Shift+F indents the following HTML as such:
Ctrl+Shift+F 将以下 HTML 缩进:
<div>
<div>
<table>
<tr>
<td>test<br />
test2
<h1>test 2</h1>
<div>testing<br />
test2</div>
<table>
<tr>
<td>
<h1>again</h1>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</div>
Anyone have any idea of how to turn this logic off (I want all tags to indent!), or customize it?
任何人都知道如何关闭此逻辑(我希望所有标签都缩进!),或自定义它?
采纳答案by bstst
I'll give you an example of how to do it in Aptana. Since it's based on Eclipse - it will be more or less the same:
我会给你一个例子来说明如何在 Aptana 中做到这一点。由于它基于 Eclipse - 它或多或少是相同的:
Window > Preferences > Aptana (or Eclipse) > Editors > HTML > Formatting > To edit, save the profile as a new one, and Edit > New lines > Everything in here should be self explanatory.
Window > Preferences > Aptana (or Eclipse) > Editors > HTML > Formatting > To edit,将配置文件另存为一个新的,并且 Edit > New lines > Everything in here 应该是不言自明的。
A sample screenshot: http://img10.imageshack.us/img10/6643/aptanaeclipse.jpg
示例截图:http: //img10.imageshack.us/img10/6643/aptanaeclipse.jpg
In case you struggle to find a menu item, just do a filter search on the top left of the Preferences dialog window.
如果您很难找到菜单项,只需在“首选项”对话框窗口的左上角进行过滤搜索即可。
回答by Rodrigo Almeida
回答by Hobo
I would suggest you look at html tidy, which is a commandline tool. If you're running linux, then fire up your package manager and search for 'tidy', it will be there. If windows, then see this page: http://tidy.sourceforge.net/#binaries
我建议你看看 html tidy,这是一个命令行工具。如果你正在运行 linux,那么启动你的包管理器并搜索“tidy”,它就会在那里。如果是 Windows,请查看此页面:http: //tidy.sourceforge.net/#binaries
Typical tidy command from bash/DOS prompt:
来自 bash/DOS 提示符的典型 tidy 命令:
tidy -im index.html
tidy -im index.html
This will (-i
) indent the code and (-m
) modify the input file (rather than spitting it on the console). It will also list any warning or errors related to the DOCTYPE you've got in your header.
这将 ( -i
) 缩进代码并 ( -m
) 修改输入文件(而不是将其吐到控制台上)。它还将列出与您在标题中获得的 DOCTYPE 相关的任何警告或错误。
After you've run the command, eclipse should notify you that you're code has been updated and prompt you to refresh the window with the updated code.
运行该命令后,eclipse 应该通知您代码已更新,并提示您使用更新后的代码刷新窗口。