Problems with formatting xml files
When I am asking IDEA to format my xml files, it does not work, that is, no lines are changed.
It has been like this for a while, but I have just put off asking about it.
Have anybody else experienced this? Just wondering if it is any of my settings that has gone haywire.
Regards,
Stig Kleppe-Jørgensen
请先登录再写评论。
Hello.
I tried to format dummy 3 lines XML in build 9720, and it works. What build are you using? Can you provide the example of non-formatted XML?
Alexander.
I tried some more now. It seems that indentation does not work, but other formatting, like attributes, are formatted correctly.
As far as I can see, the settings for indentation are ok. Do you know of anything that can make formatting attributes work correctly,
but not indentation?
I am on OS X with build 9684.
Regards,
Stig Kleppe-Jørgensen
I tried it again with build 9720 with the same results...
Regards,
Stig
Ok, build 9720.
Settings / Code Style / General / Use same settings for all file types = Off.
Settings / Code Style / General / XML / Indent = 4
Settings / Code Style / General / XML / Continuation indent = 8
Formatted the XML below. Got result (I hope our forum shows it correctly):
<?xml version="1.0" encoding="utf-8"?>
<root>
<sub-element
attr="value">
line 1
line 2
</sub-element>
</root>
All indents correspond to settings. What does not work in your case?
Alexander.
I tried to format your example file with the provided settings. Started with this:
<?xml version="1.0" encoding="utf-8"?>
<root>
<sub-element
attr="value">
line 1
line 2
</sub-element>
</root>
and got
<?xml version="1.0" encoding="utf-8"?>
<root>
<sub-element
attr="value">
line 1
line 2
</sub-element>
</root>
That is, only the attribute was moved to its correct position.
Stig
Yes, I see. It seems you have Settings / XML / Keep white spaces = On.If you set it Off, the text is aligned.
Alexander.
Thank you so much! That resolved my problem :-D
Never really did understand that option, I guess.
Regards,
Stig