Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top