Skip to main content



      Home
Home » Language IDEs » ServerTools (WTP) » HTML/JSP Formatting(HTML and JSP formatting doesn't work as I expect in eclipse with WTP)
icon5.gif  HTML/JSP Formatting [message #510871] Thu, 28 January 2010 16:53 Go to next message
Eclipse UserFriend
Eclipse isn't formatting/indenting HTML/JSP files as I expect. I will illustrate with a simple HTML.

If I create a file 1.xml, with the content:

<html><body><h1>This is a test</h1></body></html>

And the press Ctrl-f to format the code, it formats it as I expect:

<html>
     <body>
          <h1>This is a test</h1>
     </body>
</html>


However, if I do the same thing with a file 1.html, after hitting Ctrl-f, I am left with:

<html>
<body>
<h1>This is a test</h1>
</body>
</html>


No indentation. This makes large HTML files difficult to read. This situation is often worst with JSP files, where after formatting parts of tags get merged onto the same line. Sometimes the above code gets in a .jsp file gets formatted as:

<html>
<body><h1>This is a 
test</h1></body>
</html>


Does anyone know why this is happening? Why does XML formatting behave the way I expect, but HTML/JSP not?

Thanks,
John.
Re: HTML/JSP Formatting [message #510990 is a reply to message #510871] Fri, 29 January 2010 08:17 Go to previous messageGo to next message
Eclipse UserFriend
The behavior you are seeing in the HTML/JSP formatting is the expected behavior. I am a little fuzzy on the details but I know a few years back the community was telling the developers that is how they wanted HTML/JSP pages formatted with only some tags automatically indented (I think block tags?, but I know table tags are) . I do know presently that the sentiment from the community has changed and there have been more requests to see HTML/JSP formatting like that of XML.

There are already many bugs open in Bugzilla, see search here, that are requests for improving the JSP/HTML formatting experience. The team has not yet decided the best course of action for this issue but it is certainly one that is not being ignored. I suggest if you want to show your support for a fix in this area that you cast your vote on one of the bugs/enhancements that seems most like what you are looking for.

Blue Skies,

~Ian
Re: HTML/JSP Formatting [message #511049 is a reply to message #510871] Fri, 29 January 2010 11:13 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: nowhere.a.com

farrelly.john@gmail.com wrote :
> Eclipse isn't formatting/indenting HTML/JSP files as I expect. I will
> illustrate with a simple HTML.
>
> If I create a file 1.xml, with the content:
>
> <html><body><h1>This is a test</h1></body></html>
>
> And the press Ctrl-f to format the code, it formats it as I expect:
>
>
> <html>
> <body>
> <h1>This is a test</h1>
> </body>
> </html>
>
>
> However, if I do the same thing with a file 1.html, after hitting Ctrl-f, I
> am left with:
>
>
> <html>
> <body>
> <h1>This is a test</h1>
> </body>
> </html>
>
>
> No indentation. This makes large HTML files difficult to read. This
> situation is often worst with JSP files, where after formatting parts of tags
> get merged onto the same line. Sometimes the above code gets in a .jsp file
> gets formatted as:
>
>
> <html>
> <body><h1>This is a test</h1></body>
> </html>

I do not use auto-formatting in JSP files at all. Because of the way
some browsers interpret HTML, having extra white space could cause an
un-planned line break in the rendered page.

<soan><%= value1 %>&bnsp;<%= value2 %></span>

looks quite different than

<span>
<%= value1 %>
&bnsp;
<%= value2 %>
</span>

For the auto-formatter to determine when it is ok to break up lines
approaches AI capabilities.

And it is worse when you have code snippets interspersed.

--
Wojtek :-)
Re: HTML/JSP Formatting [message #512098 is a reply to message #510871] Wed, 03 February 2010 16:58 Go to previous messageGo to next message
Eclipse UserFriend
Thanks for the replies.

I just find it a bit frustrating that other IDEs (like NetBeans) format the JSP/HTML exactly as I expect, but eclipse doesn't. Eclipse is a much better IDE, and it's a pain to swap back and forth between then just to format some files ...
Re: HTML/JSP Formatting [message #646904 is a reply to message #511049] Sun, 02 January 2011 19:53 Go to previous messageGo to next message
Eclipse UserFriend
Wojtek -

This is what the <jsp:text> tg and the XSLT <xsl:text> tag are built for!

Using:

<jsp:text> </jsp:text>

is preferable to:

&nbsp;

In general, free-form text is a no-no.

Anyhow, to the original poster. YES! Eclipse sucks at this.
Join the bugzilla faction and complain!!

-Jeff
Re: HTML/JSP Formatting [message #647071 is a reply to message #510871] Tue, 04 January 2011 08:18 Go to previous message
Eclipse UserFriend
I can't seem to find the bug number but the formatting was recently revamped in WTP 3.2.x and 3.3 streams to work the way you would expect along with more options for controlling what gets indented.

The one thing I know the changes do not do is indent <body> or <head> under <html> but all other indenting happens as you describe it now.

~Ian
Previous Topic:InputStream in the WebPageEditor
Next Topic:[jsdt] possible bug in ASTParser parsing FunctionExpression
Goto Forum:
  


Current Time: Tue Jul 08 03:42:57 EDT 2025

Powered by FUDForum. Page generated in 0.41446 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top