Autoformat pom.xml without using m2eclipse plugin
Asked Answered
M

4

7

I don't use the Eclipse maven plugin while developing in Eclipse.

I generate my Eclipse classpath externally using the following command:

mvn eclipse:eclipse

This has worked fine for quite some time and I am not inclined to add a maven plugin.

However, I would like to be able to "autoformat" my pom.xml file.

My pom.xml is not showing up as a "Source" file and therefore the contextual "Source" menu doesn't show up.

Control-Shift-F doesn't work either.

Is there a way to do this without installing the m2eclipse plugin? Is there any other generic "XML Editor" plugin that can help with this?

Murphey answered 21/5, 2010 at 21:33 Comment(0)
A
14

I may be missing something obvious but why don't you use Eclipse's built-in XML Editor which supports formatting (via the regular Shift+Ctrl+F)?

Acaricide answered 21/5, 2010 at 22:0 Comment(5)
It doesn't work for me. I mentioned that in the question. Will highlight it.Murphey
Ctrl-Shift-F appears to work only for "Source" files. Since the pom.xml is not a source file, it doesn't work for it.Murphey
@Murphey It definitely works for me with any XML file when I open them with the XML Editor which is part of Eclipse for Java (right-click on an XML file then Open With > XML Editor). If you don't have it, install it (I think it's part of Eclipse WTP).Acaricide
Sorry. It works with XML Editor. My eclipse was opening it with the standard text editor for some weird reason. Thanks.Murphey
This level of complexity is not easy to understand.Bradwell
L
1

So, I found a way -

  1. Select source of pom.xml (ctrl+A).
  2. Click right button of mouse.
  3. Then click Source > Cleanup Document.
  4. Check "Format Source" in popup and uncheck all other options.

it's Done!! :)

Leupold answered 19/2, 2018 at 8:8 Comment(0)
S
1

Use ctrl + shift + F keys together, for me left side of ctrl + shift key combination of laptop did't work I tried with right side combination and it worked.

Situs answered 23/7, 2020 at 11:51 Comment(0)
T
0

This problem occurs only when we open in text editor. Solution works when we open the pom.xml in xml editor and use the short cut commands as shft+ctl+F

Toshiatoshiko answered 3/4, 2019 at 16:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.