eclipse 如何更改eclipse html格式

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18418230/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 21:06:53  来源:igfitidea点击:

how to change eclipse html formatting

htmleclipseformatting

提问by Lena Bru

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

当我在 Eclipse 中打开一个 html 文件时,格式化它后,它看起来像这样:

<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?

我如何让 eclipse 理解这一点?

回答by ali akbar azizkhani

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

要像往常一样更改格式,请转到 Window->Preferences->Web->HTML Files->Editor,然后删除所有内联元素,如下所示:

enter image description here

在此处输入图片说明

回答by RoiEX

Under

在下面

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

窗口->首选项->Web->HTML 文件->编辑器

there are some options in terms of HTML formatting.

在 HTML 格式方面有一些选项。

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

与 Java 相比,几乎没有可用的选项,但也许您可以弄清楚该怎么做。

回答by Khaled Obaid

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

您可以在此处找到如何在 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.

转到窗口->首选项->Java->代码样式->格式化程序。创建新的格式化程序。单击编辑,然后选择选项卡换行并将换行策略设置为不换行。

回答by Aashish Verma

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

转到窗口->首选项->Web->HTML 文件->编辑器

  1. Remove all inline elements
  2. Set Line width to 200 or more
  3. set indentation size at 1
  1. 删除所有内联元素
  2. 将线宽设置为 200 或更多
  3. 将缩进大小设置为 1

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

应用并关闭,现在按ctrl+Shift+F格式化您的代码

enter image description here

在此处输入图片说明