Sublime Text 2:基于上下文的不同语言突出显示?(a la Webstorm) [英] Sublime Text 2: Different language highlighting based on context? (a la Webstorm)

查看:28
本文介绍了Sublime Text 2:基于上下文的不同语言突出显示?(a la Webstorm)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 ).我使用 PlistJsonConverter 从 JSON 到 plist,然后将文件保存为 .tmLanguage.希望这会有所帮助.

I was watching some videos on Egghead.io about AngularJS. The creator of the videos uses Webstorm (and, I believe, works for them). One feature I noticed is that he can set different syntax highlighting within different scopes or quotation marks. So, in code like the following (from an AngularJS directive)

return {
    template: '<div>something</div>',
    //         ^^^ these guys ^^^
}

...he can get the inside of the quotation marks to highlight as HTML.

I use Sublime Text 2, and am fairly wedded to it. Is there an existing feature/plugin for Sublime that could handle a case like this? If not, is something like this technically possible using the Sublime Text 2 API?

解决方案

I don't think it's built in, but it's certainly possible. I've been doing some work with graphviz and wanted to do something similar. Labels can be generated with html like syntax. Anyways, I played around with the .tmLanguage file and added a new pattern to match the context where html like entries were valid (I look for label = <). The patterns I used for the captures aren't that good, but it works for fine for me. This give me the following, which I think is similar to what you are looking for.

I don't know anything about AngularJS, so I can't help you with anything specific to that, but it is certainly possible. Note that in the image below, the last <table></table> are just to show that highlighting doesn't occur there.

Edit:

Forgot to include this in the original post, but here is my updated tmLangauage file. That first pattern is what I added(link). I used PlistJsonConverter to go from JSON to plist, then saved the file as .tmLanguage. Hope this helps.

这篇关于Sublime Text 2:基于上下文的不同语言突出显示?(a la Webstorm)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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