Custom JavaScript snippets for emmet (in Sublime Text 2)

I am trying to add some custom javascript snippets and abbreviations to the snippets.json Emmet file, but I can't get it to work! (I am using Sublime Text 2.)

If I put this at the end of settings.json

"javascript": { "abbreviations": { "while": "while(true)\n{\n\t\n}" }, "snippets": { "asdf": "qwerty" } } 

Nothing happens. (I set the file syntax to javascript, obviously)

But if I replaced 'javascript' with 'css':

 "css": { "abbreviations": { "while": "while(true)\n{\n\t\n}" }, "snippets": { "asdf": "qwerty" } } 

it correctly overwrites inline CSS snippets and works great. (I obviously set the syntax in css [otherwise it DOES NOT work])

What am I missing? according to this: http://docs.emmet.io/customization/snippets/ Thus, I should be able to define fragments for custom languages.

Note. I also tried 'js' for the language name.

+4
source share
1 answer

You should use js as the syntax name, since Sublime Text defines the JavaScript scope as source.js . In the future, you should use the source.(SYNTAX_NAME) for the syntax name.

And you should not use the abbreviations section for fragments, as abbreviations define blocks of elements and must be written as an HTML element. Use the snippets section.

Note that in JS files in the ST editor, you need to use Ctrl + E to expand the abbreviations, since the Tab key is disabled for this syntax.

And, as Protractor Ninja noted, it was nice to use Emmet snippets in editors that support native ones.

+8
source

Source: https://habr.com/ru/post/1484475/


All Articles