Eclipse html: Doesn't indent on some tags
For some r开发者_Go百科eason, Eclipse seems to think that e.g. <div>
and <td>
tags aren't indenting-worthy.
Ctrl+Shift+F indents the following HTML as such:
<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?
Window > Preferences > Web > HTML Files > Editors.
Remove what you want to indent of the "Inline Elements" field.
This solved for me.
Hope its better now.
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:
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.
A sample screenshot: 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.
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
Typical tidy command from bash/DOS prompt:
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.
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.
精彩评论