Reputation: 3988
In Eclipse I need to format XML like I do on Java with Formatter when CtrlShiftF pressed.
The use of CtrlShiftF on XML does not provide the results that I want.
Is there a tool like: "Window→Java→Code Style→Formatter" to do the job?
The: "Window→XML→XML Files→Editor" and "Window→Editors→Text Editors" lacks a lot of features, like "Window→Java→Code Style→Formatter→Edit→Indentation→Align fields in columns" so ther XML result will be like:
android:id = "@+id/textView1"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
I don't care if it's an external plug-in or a lib. I use Eclipse 4.2.0 Juno for Android development.
Upvotes: 2
Views: 2567
Reputation: 9090
Markup languages cannot be formatted as Java code. Despite that, you can assign the default html
editor with the .xml
file type as follows:
Window -> Preferences -> General -> Editors -> File Associations
Select the .xml
from the top box and assign it to the Html editor
from the bottom box. Also you can set it as default.
Doing this will enable markup highlighting for all .xml
files and you can use the default CtrlShiftF shortcut to format your xml file.
This formatting can be parametrized from General->Editors->Structured Text Editors
. There are no many options there but it will do the job. Also, you can try using other formatters like the php
one (I think it requires PDT to be installed to eclipse).
If you are only interesting in understanding the structure of an xml file, than just formatting it:
Hope that helps
Upvotes: 2
Reputation: 16392
There should be a menu option on the editor's context menu Source -> Format
Upvotes: 0