如何让 Zen Coding 在 Sublime Text2 中支持 JavaScript 文件? [英] How to make Zen Coding support JavaScript files in Sublime Text2?

查看:24
本文介绍了如何让 Zen Coding 在 Sublime Text2 中支持 JavaScript 文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

RT~ Sublime Text2 是我最喜欢的编辑器之一.对我来说唯一的问题是它的 Zen Coding 插件只支持 css 和 html 文件.但是有很多情况需要在 JavaScript 或其他文件中使用 Zen Coding.就像,在 js 中使用 html 模板或在 js 中使用 concat 字符串.

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.

我在 ~/.config/sublime-text-2/Packages/ZenCoding 中检查了它的包文件.但我不知道如何配置它以支持更多文件.

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.

推荐答案

打开 Packages/ZenCoding/sublimezenplugin.py在`#########CONSTANTS######### 之后,应该有:

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

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

添加以下内容:

JS                        = 'source.js'

然后向下滚动到它说的地方:

Then scroll down to where it says:

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

并将其更改为:

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

这将在 JS 文件中激活 zencoding;但是,请注意 Zencoding 将始终在 js 文件中处于活动状态.如果您想将范围限制为 JS 中的字符串,您可以更改范围.JS 字符串的作用域是 string.quoted.double.js 双引号和 string.quoted.single.js.您可以将这两个添加到 JS = ... 行.随意试验范围以适应您的喜好.有关范围的更多信息,请查看此处的文档:http://readthedocs.org/docs/sublime-text-unofficial-documentation/en/latest/extensibility/syntaxdefs.html

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

此外,要查看光标下的当前范围,Windows/Linux 的键绑定是 ctrl+alt+shift+p,OSX 的键绑定是 alt+command+p.

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.

这篇关于如何让 Zen Coding 在 Sublime Text2 中支持 JavaScript 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆