簡體   English   中英

如何配置Eclipse XML格式?

[英]How to configure Eclipse XML formatting?

我想改變Eclipse格式化XML文件的方式。 例如,如果我在pom.xml文件中有如下部分:

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>

在ctrl + shift + f后,它將如下所示:

    <dependency>
        <groupId>
            junit
        </groupId>
        <artifactId>
            junit
        </artifactId>
        <version>
            3.8.1
        </version>
        <scope>
            test
        </scope>
    </dependency>

我更喜歡第一個版本,那么如何配置Eclipse來格式化XML文件呢?

窗口 - >首選項,然后是XML - > XML文件 - >編輯器。 在首選項樹上方有一個搜索框,當您想要查找某些內容的配置時非常有用。

請注意,可能是使用了其他編輯器,例如,如果您正在編輯build.xml文件並具有Ant集成。 在這種特定情況下,您可以在Window - > Preferences,Ant - > Editor - > Formatter中設置格式。 在類似的情況下,您需要自己搜索該編輯器的相應選項。

我有解決方案所以你應該去Preferences-> Andriod-> Editors並禁用第一行“使用標准Android XML格式化XML文件......”這是解決方案。 我猜它與安裝ADT插件有關。

試試這個

Window-> Preferences-> XML-> XML Files-> Editor ...在Formatting-> Line width下

增加寬度值(比如150),直到您需要標記格式

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM