Eclipse html: Doesn't indent on some tags
Asked Answered
M

3

17

For some reason, 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?

Mera answered 5/1, 2011 at 16:30 Comment(1)
I believe this question is on-topic. Eclipse is a programmer's tool. So I am surprised someone votes to close it.Lohengrin
P
8

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.

Poland answered 11/1, 2011 at 16:3 Comment(1)
Thanks a lot! That would have been awesome - but Eclipse does not have this menu. Apparently the entire Aptana menu is new. But thanks for the heads-up on Aptana - those preferences alone look very nice! I now actually believe Eclipse Helios (current release) have no options of doing this, and that this is actually a feature, not a bug! If you rename the file to .xml, and then reformat it, sanity ensues directly.Mera
D
16

Window > Preferences > Web > HTML Files > Editors.

Remove what you want to indent of the "Inline Elements" field.

enter image description here

This solved for me.

Hope its better now.

Depressomotor answered 21/8, 2013 at 19:7 Comment(1)
A sentence or two could make this a more useful answer.Landseer
P
8

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.

Poland answered 11/1, 2011 at 16:3 Comment(1)
Thanks a lot! That would have been awesome - but Eclipse does not have this menu. Apparently the entire Aptana menu is new. But thanks for the heads-up on Aptana - those preferences alone look very nice! I now actually believe Eclipse Helios (current release) have no options of doing this, and that this is actually a feature, not a bug! If you rename the file to .xml, and then reformat it, sanity ensues directly.Mera
K
2

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.

Kosaka answered 25/3, 2011 at 10:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.