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

7 comments
Comment actions Permalink

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.

0
Comment actions Permalink

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

0
Comment actions Permalink

I tried it again with build 9720 with the same results...

Regards,
Stig

0
Comment actions Permalink

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.

0
Comment actions Permalink

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

0
Comment actions Permalink

Yes, I see. It seems you have Settings / XML / Keep white spaces = On.If you set it Off, the text is aligned.

Alexander.

1
Comment actions Permalink

Thank you so much! That resolved my problem :-D

Never really did understand that option, I guess.

Regards,
Stig

0

Please sign in to leave a comment.