J.Menshov
J.Menshov

Reputation: 93

Indentation of HTML in PHP files within PhpStorm

In a .php file I have a the following code

<? include 'header.php' ?>
    <form action="/">
        <input>
    </form>
<? include 'footer.php' ?>

How can I delete the 4 indents before the HTML tag when I press Ctrl+Alt+L? It should look like this:

<? include 'header.php' ?>
<form action="/">
    <input>
</form>
<? include 'footer.php' ?>

Upvotes: 7

Views: 2192

Answers (3)

Daerik
Daerik

Reputation: 4277

It's a bug with PhpStorm. Until it is fixed, simply put a new line after your last closing PHP tag.

<? include 'header.php' ?>
<form action="/">
    <input>
</form>
<? include 'footer.php' ?>
// new line here

Upvotes: 6

Kevin
Kevin

Reputation: 1723

The Ctrl+Alt+L is the shortcut for Reformat Code, which automatically applies the code indentation rules set in the PhpStorm settings.

It is currently not possible to make the code look like you want automatically. You would have to format the code manually every time.

The reason is the limitation of the PhpStorm formatting engine. There is already feature request at the PhpStorm issue tracker which addresses the issue: WI-32401
Also see this issue report: WI-17786

Upvotes: 5

Naqash Malik
Naqash Malik

Reputation: 1816

Select area before form tag with mouse middle button then delete how much area you want to remove. Holding mouse middle button will select columns (indents). Hope it will help you in some other situations too.

Upvotes: 0

Related Questions