admin 管理员组文章数量: 1086019
I am trying to add some custom javascript snippets and abbreviations to the snippets.json file of Emmet, but I can't get it to work! (I am using Sublime Text 2.)
If I put this into the end of the settings.json
"javascript": {
"abbreviations": {
"while": "while(true)\n{\n\t\n}"
},
"snippets": {
"asdf": "qwerty"
}
}
nothing happens. (I set the syntax of the file to javascript obviously)
But if I replace 'javascript' with 'css':
"css": {
"abbreviations": {
"while": "while(true)\n{\n\t\n}"
},
"snippets": {
"asdf": "qwerty"
}
}
it correctly overwrites the built in CSS snippets, and works fine. (I obviously set the syntax to css [otherwise it does NOT work])
What am I missing? according to this: / I should be able to define snippets for custom languages this way.
Note: I have tried 'js' for the language name too.
I am trying to add some custom javascript snippets and abbreviations to the snippets.json file of Emmet, but I can't get it to work! (I am using Sublime Text 2.)
If I put this into the end of the settings.json
"javascript": {
"abbreviations": {
"while": "while(true)\n{\n\t\n}"
},
"snippets": {
"asdf": "qwerty"
}
}
nothing happens. (I set the syntax of the file to javascript obviously)
But if I replace 'javascript' with 'css':
"css": {
"abbreviations": {
"while": "while(true)\n{\n\t\n}"
},
"snippets": {
"asdf": "qwerty"
}
}
it correctly overwrites the built in CSS snippets, and works fine. (I obviously set the syntax to css [otherwise it does NOT work])
What am I missing? according to this: http://docs.emmet.io/customization/snippets/ I should be able to define snippets for custom languages this way.
Note: I have tried 'js' for the language name too.
Share Improve this question asked Jun 4, 2013 at 18:00 Isti115Isti115 2,7963 gold badges36 silver badges38 bronze badges 2- 1 What about the Snippets page implies that you can add support for custom languages? I don't think Emmet is designed for Javascript; you'd probably be better off with something like SublimeCodeIntel to power up your Javascript development. Still, this question might help you (Emmet used to be called Zen Coding), though I don't know for certain. – angerson Commented Jun 4, 2013 at 20:18
- Thank you, the question you linked is very helpful, but I decided to use Sublime's built-in Snippets. – Isti115 Commented Jun 5, 2013 at 19:09
1 Answer
Reset to default 8You should use js
as syntax name since Sublime Text defines JavaScript scope as source.js
. In future, you should use source.(SYNTAX_NAME)
part for syntax name.
And you shouldn’t use abbreviations
section for snippets since abbreviations defines element blocks and should be written as HTML element. Use snippets
section.
Note that in JS files in ST editor you have to use Ctrl+E to expand abbreviations since Tab key is disabled for this syntax.
And, as Protractor Ninja noted, it’s not a good idea to use Emmet snippets in editors that supports native ones.
本文标签: customizationCustom JavaScript snippets for emmet (in Sublime Text 2)Stack Overflow
版权声明:本文标题:customization - Custom JavaScript snippets for emmet (in Sublime Text 2) - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/p/1744033759a2521981.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论