views:

288

answers:

1

When auto-formatting JSP files in Eclipse using Ctrl+Shift+F, it is trying to fit as many tags on a line as possible and then the tag that doesn't fit it will break and place the attributes on the next line.

This is created very messy code, example below.

        <div class="type-text"><label for="echo">Project Name: </label> <s:textfield
            id="projectName"
            name="projectName"
            value="Project Name"
        >
        </s:textfield></div>

Does anyone know how to format JSP files better?

+1  A: 

Hard, but true: just don't use it. Eclipse is great with Java(EE), but weak with (X)HTML/JSP in general. IntelliJ is better here. In Eclipse you just have to already write nice intented (X)HTML/JSP code. You can however configure several parameters in preferences by Web > HTML files > Editor, such as the Line Width. But still, it doesn't indent code nicely.

BalusC
It really is unusable. I am using the options "Split multiple attributes each on a new line" + "Align final bracket in multi-line element tags" in Web > HTML files > Editor but it's still terrible.I will have a look at IntelliJ.
reckoner