Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I keep my indentation for the blade syntax in PHPStorm?

I am copying the following code from a *.blade.php file:

@section('content')
    <h1>All Users</h1>

    @if ($users->isEmpty())
        <h2>No Users Found</h2>
    @else
        @foreach ($users as $user)
            <li>{{ link_to("/users/{$user->username}", $user->username) }}</li>
        @endforeach
    @endif
@stop

This is how it appears when it is pasted into the same file:

@section('content')
    <h1>All Users</h1>

@if ($users->isEmpty())
        <h2>No Users Found</h2>
@else
@foreach ($users as $user)
            <li>{{ link_to("/users/{$user->username}", $user->username) }}</li>
@endforeach
@endif
@stop

I am assuming there is a code style somewhere that is removing the indents for the blade syntax, but I can't find which one. What setting do I need to change?

like image 250
zeckdude Avatar asked Oct 20 '25 20:10

zeckdude


1 Answers

Generally speaking:

Settings (Preferences on Mac) | Editor | Smart Keys | Reformat on Paste

Why "generally" -- because there is no proper Blade support available in PhpStorm yet (but coming soon) and therefore no separate formatter rules for it. Because of that the aforementioned option most likely be the one responsible for such behaviour.

like image 75
LazyOne Avatar answered Oct 23 '25 11:10

LazyOne



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!