Format XML code in Eclipse

前端 未结 6 527
面向向阳花
面向向阳花 2020-12-02 17:52

When I write .xml files in Eclipse, I often have to manually indent code. For example




        
相关标签:
6条回答
  • 2020-12-02 18:29

    As stated above, Ctrl+Shift+F will auto-format. However, by default Eclipse will split attributes in a naive way. If you're like me and prefer to have all the attributes on their own lines, go to Window→Preferences→XML→XML Files→Editor and check Split multiple attributes each on a new line.

    0 讨论(0)
  • 2020-12-02 18:46

    You need to open the file using the XML Editor, swap to Source view and then do the Ctrl + Shift + F trick.

    0 讨论(0)
  • 2020-12-02 18:47

    You can set the default XML editor to “Java Editor”:

    • Right-click on the XML
    • Open With
    • Other...
    • Java Editor

    This applies all java formatting and controls over XML file.

    0 讨论(0)
  • 2020-12-02 18:49

    CMD + SHIFT + F for Macintosh users

    0 讨论(0)
  • 2020-12-02 18:49

    open windows->preferences->xml files->editor enter some high number for line width, say 999 and then format the xml file with ctrl+shift+F.

    You ll see the lines are aligned properly.

    0 讨论(0)
  • 2020-12-02 18:52

    Ctrl+Shift+F

    Will do it for you, and you can configure it in

    Window -> Preferences -> XML -> Xml Files -> Editor
    
    0 讨论(0)
提交回复
热议问题