nadaram
nadaram

Reputation: 101

How use Emmet in PHPStorm in PHP files?

Emmet only works in HTML & CSS files How can I use it in PHP files in the IDEs like PHPStorm?

<?php echo "p>li*5"; ?>

Upvotes: 5

Views: 5631

Answers (2)

Guilherme Carvalho
Guilherme Carvalho

Reputation: 63

For those who are wondering how to get the Emmet to work in .php files but outside the tags (to generate HTML), just press Tab after the Emmet command. Like:

<?php if($variable === true): ?>
    span.sometext*3 (press ->Tab)
<?php endif; ?>

It generates the following code:

<?php if($variable === true): ?>
    <span class="sometext"></span>
    <span class="sometext"></span>
    <span class="sometext"></span>
<?php endif; ?>

It's important to tell this because PHPStorm does not show it anywhere, no inline tips, no shortcut tip, neither in that "tips lamp".

Upvotes: 2

xjmdoo
xjmdoo

Reputation: 1736

In PHPStorm, you can just type echo "p>li*5" and then make sure your cursor is still inside the quotes and it is at the end of your Emmet string. Hit Alt + Enter, then select Inject Language / Reference. You will get a list of languages and you can filter by typing. Select html and tab completion will work just as in an HTML file.

Upvotes: 2

Related Questions