Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to re-format an XML file in Phpstorm?

Tags:

xml

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>
      ...
like image 817
hakre Avatar asked Jan 01 '13 12:01

hakre


People also ask

How can I get beautify code in Phpstorm?

In the editor, select a code fragment you want to reformat. Before reformatting, you can take a look at the code style settings that are applied to the selected code: press Alt+Enter and click Adjust code style settings. From the main menu, select Code | Reformat Code or press Ctrl+Alt+L .


1 Answers

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?

like image 89
LazyOne Avatar answered Oct 07 '22 01:10

LazyOne