Sublime Forum

Emmet : Delete or modify snippet for HTML5

#1

Hi, I’m wondering how one goes about modifying the snippet when using Emmet and the bang (!) + TAB. This will output a snippet with a basic HTML5 doctype and structure. I can’t find where this snippet is saved and I can’t seem to overwrite the snippet with one of my own.

Anyone know?

thanks!

0 Likes

#2

Packages\Emmet\emmet\snippets.json

"html":{ ... "abbreviations":{ "!": "html:5", ... "html:5": "<!doctype html>\n<html lang=\"${lang}\">\n<head>\n\t<meta charset=\"${charset}\">\n\t<title>${1:Document}</title>\n</head>\n<body>\n\t${child}${2}\n</body>\n</html>" } }

0 Likes

#3

This snippet is defined in plugins’ snippets.json file: docs.emmet.io/cheat-sheet/

To override it, read docs.emmet.io/customization/
In Sublime Text, you can put your own snippets into Users’ Emmet.sublime-settings, like this: github.com/sergeche/emmet-subli … ttings#L77

0 Likes

#4

Great! Thanks guys.

I have one more question that is more about snippets in general. When using a snippet, you have these “tab stops” (i.e. ${1:something} ) for areas you want to jump to. It seems that Emmet doesn’t fire until you have gone through all the tab stops.

For example, if I hit “! TAB” I get the following (obviously without the [tab stops]):

[code]<!doctype html>

[Document] [tab stop] [tab stop][/code] If I jump to the second tab stop and then type "ul>li TAB" nothing happens because I'm still in snippet population mode. This is shown as being in "Field 2 of 3" in the status bar. I have to hit TAB 3 times, then jump back to the body and try the Emmet expansion once more for it to work.

Am I doing something wrong?

0 Likes

#5

[quote=“skube”]Great! Thanks guys.

I have one more question that is more about snippets in general. When using a snippet, you have these “tab stops” (i.e. ${1:something} ) for areas you want to jump to. It seems that Emmet doesn’t fire until you have gone through all the tab stops.

For example, if I hit “! TAB” I get the following (obviously without the [tab stops]):

[code]<!doctype html>

[Document] [tab stop] [tab stop][/code] If I jump to the second tab stop and then type "ul>li TAB" nothing happens because I'm still in snippet population mode. This is shown as being in "Field 2 of 3" in the status bar. I have to hit TAB 3 times, then jump back to the body and try the Emmet expansion once more for it to work.

Am I doing something wrong?[/quote]

You are not doing anything wrong. It’s just a priority thing.
I overrode this snippet with the same one but without the very last tab stop. So it works nicely for me.

0 Likes

#6

But that’s the thing, the last tab stop is not explicitly stated. I didn’t put it in, it just always will jump to the very end (after the /html) - even if I have no tab stops defined.

0 Likes

#7

I have this in my User/Emmet
snippets.json

{ "html": { "filters": "html", "snippets": { "html:5": "<!doctype html>\n<html lang=\"${lang}\">\n<head>\n\t<meta charset=\"${charset}\">\n\t<title>${1:Document}</title>\n</head>\n<body>\n\t${child}$0\n</body>\n</html>" } } }

The $0 handles this. $0 was not implemented a while ago, until I reported it as an issue.
https://github.com/sergeche/emmet-sublime/issues/121
Now it just works like Sublime snippets.

0 Likes

#8

Sweet thanks! Exactly what I was looking for.

0 Likes