coreinsanity's avatar

PHPStorm Blade auto-indenting too far on closing statements

This is getting really irritating. At first it was minor, I can just shift-tab and it goes back, but it's just getting annoying.

Whenever I start coding a blade template and put something (anything) that has a closing in, such as @foreach, and hit enter, it autocompletes and indents the closing like so:

@foreach($a as $b)
    @endforeach

Though honestly, it doesn't just do this with blade. It does it with other things too. I don't remember what, I think Javascript, but I notice it most in Blade.

I've had this issue since the Blade support came in, I'm using the latest EAP now and it's still there. I can't seem to find anything to fix it.

Edit:

To add, is there a way to make it act more visual-studio-like and do this when you hit enter and it autocompletes?

@foreach($a as $b)
    *cursor here*
@endforeach
0 likes
8 replies
mstnorris's avatar

PhpStorm is heavily customisable so it is possible, you just need to edit the Code Style.

Blade specific Settings

General PHP Settings

All the tabs in the right pane can be inspected and you can configure til your heart's content

Smart indent (Although this should be set already if you're using Blade and Laravel Plugin)

1 like
jimmck's avatar

You need to change the smart indent settings to your accepted likings in the editor settings.

coreinsanity's avatar

Thanks for the replies, though I've messed with these settings before, the only way I have ever been able to get it to do it is to make it stop doing any kind of auto-indenting across the board.

  • My blade code style window already looks like that screen. Yet it still indents the @endforeach. (it looks identical to your ss)
  • I've messed with the smart indent settings, doesn't make any difference short of turning smart indent off (which does it globally...)
  • The PHP code styling doesn't have anything relevant to Blade, that I can see.

The issue I see is that it doesn't autocomplete the closing blade statements. You type the blade statement (eg: @foreach()), hit enter and it indents as if you're typing the code block that should be inside of it, but never puts in the closing @endforeach.

I don't see a setting to fix this.

coreinsanity's avatar

@mstnorris I'll try that on Monday when I get back to work, or this weekend if I end up doing any web stuff (doubt it though, pretty busy), thanks! It looks nice.

coreinsanity's avatar

@mstnorris So I had a chance to get those working this morning, it looks like those will work good. Thanks! Will take some getting used to for hitting the live templates shortcut, but that's not bad. I should be using it more anyway.

Please or to participate in this conversation.