How to Format Laravel Blade Code in Visual Studio Code?
You can use the Laravel Blade Snippets extension for Visual Studio Code to format Blade code in your Laravel projects.
You can use the Laravel Blade Formatter extension by mblode for Visual Studio Code to format Blade code in your Laravel projects. Here's an example of how to use the extension to format your Blade templates:
- Install the Laravel Blade Formatter extension by searching for it in the Visual Studio Code Extension Marketplace.
- Open a new or existing Blade file in Visual Studio Code.
- Use the built-in format document shortcut: press
Shift + Alt + F(Windows/Linux) orShift + Option + F(Mac). Alternatively, right-click in the editor and select Format Document. - For automatic formatting on save, add
"editor.formatOnSave": trueto your VS Codesettings.jsonfile.
Example:
Example of formatted Laravel Blade Code in Visual Studio Code
@section('content')
<h1>Welcome to my website</h1>
<p>Here is some content for the website.</p>
@endsectionThis will properly indent and structure your Blade directives.
Note: The extension also provides syntax highlighting, autocompletion, and formatting rules for Blade-specific constructs to make your development experience more efficient.