2

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
  • 1
    Despite being the best editor out there, like the one we all spend time trawling the net for, you will still come across other quite basic things that it does not do... you can not print for example. Commented Mar 6, 2012 at 5:20

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.