Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

almo's avatar
Level 3

[ST3] How to expand custom tags within Sublime Text ?

Hello,

I'd like to expand custom HTML tags by pressing tab within Sublime Text 3. Is there a way to do this ? Any package to install ?

Exemple :
I type custom, then press the tab key. I'd like to get <custom></custom>.

Thanks !

A.

0 likes
6 replies
almo's avatar
Level 3

I've installed Emmet but can't figure out how mytag can expand into <mytag></mytag> without specifying every custom tags into Emmet settings.

Emmet works fine with common HTML tags like paragraphs or headings, but do not act as expected with custom ones.

Any idea ?

saethor's avatar
saethor
Best Answer
Level 3

You can use ctrl + e and that expands custom tags with emmet

2 likes
stevenobird's avatar

Take a look at the Emmet Default Settings, there is a section for "snippets", in which you can add your own. Copy the small block and paste it into your User Settings (Emmet, of course):

{
    "snippets": {
        "html": {
            "abbreviations": {
                "example": "<div class='example' title='Custom element example'>"
            }
        }
    },
}

I took Emmet's example for this - when you now enter "example" (the key in the abbreviations object) and press Tab, Emmet should now replace it by "".

Take a look into the Docs: http://docs.emmet.io/customization/snippets/ http://docs.emmet.io/abbreviations/types/

EDIT: My approach is of course for more advanced custom tags, the one of @saethor might be the right choice for you if it is just for expanding your "word" into a "tag" by Pressing CTRL + E.

qgates's avatar

The default Emmet behaviour when editing HTML syntax or scopes is that only known HTML tags will be expanded. This behaviour is by design so that Emmet won't override other snippets and expansions in various HTML contexts.

However, in modern webdev we're using semantic markup more of the time (eg. Vue) so there is a case for fixing this behaviour.

To fix, override the Emmet setting disabled_single_snippet_for_scopes in your Emmet user settings to allow my-custom[tab] to expand to <my-custom></my-custom>.

There are a few gotchas with this, since certain default sublime snippets won't work. You can exclude specific scopes to fine tune this behaviour, so for instance:

"disabled_single_snippet_for_scopes": "embedding.php",

Will allow php[tab] to expand to <?php ?> when editing PHP files, bypassing Emmet's tag expansion.

1 like

Please or to participate in this conversation.