How to make Zen Coding support JavaScript files in Sublime Text2?

牧云@^-^@ 提交于 2019-12-21 21:40:22

问题


RT~ Sublime Text2 is one of my favorite editors. The only problem to me is that its Zen Coding plugin only support css and html files. But there are many situations that to use Zen Coding in JavaScript or other files. Just like, use html template in js or concat strings in js.

And I checked its pakage file in ~/.config/sublime-text-2/Packages/ZenCoding. But I don't kown how to configure it to support more files.


回答1:


Open up Packages/ZenCoding/sublimezenplugin.py Right after `#########CONSTANTS#########, there should be:

HTML                      = 'text.html - source'
XML                       = 'text.xml'

Add the following:

JS                        = 'source.js'

Then scroll down to where it says:

ZEN_SCOPE = ', '.join([HTML, XML, CSS])

And change that to:

ZEN_SCOPE = ', '.join([HTML, XML, CSS, JS])

This will activate zencoding in JS files; however, beware that Zencoding will ALWAYS be active in js files. If you want to limit the scope to, say, strings in JS, you can change the scope. The scopes of JS strings is string.quoted.double.js for double quotes and string.quoted.single.js. You can add both of these to the JS = ... line. Feel free to experiment with the scope to fit it to your liking. For more info on scopes, check out the documentation on it here: http://readthedocs.org/docs/sublime-text-unofficial-documentation/en/latest/extensibility/syntaxdefs.html

Also, to see the current scope immediately under the cursor, the keybinding for Windows/Linux is ctrl+alt+shift+p and for OSX is alt+command+p.



来源:https://stackoverflow.com/questions/9578259/how-to-make-zen-coding-support-javascript-files-in-sublime-text2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!