24

When i open an html file in eclipse, after i format it, it looks like this:

<form>
            <fieldset>
                <label for="memberName">Login Name:</label> <input type="text"
                    name="memberName" id="memberName" value=""
                    class="text ui-widget-content ui-corner-all" /> <label
                    for="memberPass">Password:</label> <input type="password"
                    name="memberPass" id="memberPass" value=""
                    class="text ui-widget-content ui-corner-all" />


            </fieldset>
        </form>

but i want each tag with all of its attributes on the same line

how do i make eclipse understand that?

Lena Bru
  • 13,521
  • 11
  • 61
  • 126
  • 3
    This is called _word wrap_. Try this [link](http://stackoverflow.com/a/3242397/1763929) – Vucko Aug 24 '13 at 11:51
  • 1
    You need to stop Eclipse from line wrapping. See these other SO questions: [http://stackoverflow.com/questions/890805/stop-eclipse-from-line-wrapping](http://stackoverflow.com/questions/890805/stop-eclipse-from-line-wrapping) [http://stackoverflow.com/questions/2005929/howto-prevent-eclipse-from-line-wrapping-in-xml-and-html-files](http://stackoverflow.com/questions/2005929/howto-prevent-eclipse-from-line-wrapping-in-xml-and-html-files) – htxryan Aug 24 '13 at 11:52

4 Answers4

9

To change the formatting as usual, go to Window->Preferences->Web->HTML Files->Editor, and remove all inline Elements like this:

enter image description here

peterh
  • 11,875
  • 18
  • 85
  • 108
ali akbar azizkhani
  • 2,213
  • 5
  • 31
  • 48
4

Under

Window->Preferences->Web->HTML Files->Editor

there are some options in terms of HTML formatting.

In comparison to Java, there are almost no options available, but maybe you can figure out on what to do.

peterh
  • 11,875
  • 18
  • 85
  • 108
RoiEX
  • 1,186
  • 1
  • 10
  • 37
4

Go to Window->Preferences->Web->HTML Files->Editor

  1. Remove all inline elements
  2. Set Line width to 200 or more
  3. set indentation size at 1

Apply and Close, Now format your code by pressing ctrl+Shift+F

enter image description here

Aashish Verma
  • 103
  • 1
  • 11
2

You can find the answer here how to turn off break line in eclipse

Follow these steps to Not wrap.

Go to Window->Preferences->Java->Code Style->Formatter. Create new formatter. Click on edit and then pick tab Line Wrapping and set Line Wrapping policy to Do not wrap.

Community
  • 1
  • 1
Khaled Obaid
  • 275
  • 3
  • 13