Search code examples
xmlphpstorm

How to re-format an XML file in Phpstorm?


I'm using Phpstorm and I have some XML file that is a single line only but contains a lot of (nested) elements. Just a common XML file:

<?xml version="1.0" encoding="UTF-8"?>
<response><status><version>4.2</version><code>0</code><message>Success</message></status><songs><song>...

(gist of the full XML).

Having that file opened, I want to re-format it with indenting.

I have tried using Reformat Code... (Ctrl + Alt + L) but it didn't change anything. I also reviewed the XML Code-Style Settings, but I don't see anything standing in the way.

Isn't it possible for Phpstorm to re-format an XML file to indent nested XML elements?

Something into the direction like:

<?xml version="1.0" encoding="UTF-8"?>
<response>
  <status>
    <version>4.2</version>
    <code>0</code>
    <message>Success</message>
  </status>
  <songs>
    <song>
      ...

Solution

  • Works for me (tried on full XML, not snippet) -- it took about 5-7 seconds to do .. but did it properly (PhpStorm v6 EAP build 124.373).

    Most likely it's your settings (Code Style | XML | Other): maybe you have "Keep line breaks" option checked or similar option?