【问题标题】:Sublimetext 3 & AngularJS - Syntax highlighting (HTML)Sublimetext 3 & AngularJS - 语法高亮 (HTML)
【发布时间】:2015-08-22 03:00:06
【问题描述】:

是否有一些用于 angularjs html 模板的语法荧光笔?

例子

ng-click="someVariable"

我希望 someVariable 与"" 之间的其他字符串不同地突出显示,或者至少我希望 ng-someDirective 突出显示。

【问题讨论】:

    标签: angularjs syntax-highlighting sublimetext3


    【解决方案1】:

    强烈推荐你使用这个包:

    https://github.com/angular-ui/AngularJS-sublime-package

    它为您提供自动完成功能和其他功能。

    关于语法高亮,我有这样的:

    关于语法高亮,您必须更改html语法解析器。

    您必须导航到安装文件夹中的 Packages 文件夹(我的是 /opt/sublime_text/Packages)。

    然后您打开Color Scheme - Default.sublime-package(使用任何 ZIP 资源管理器),然后编辑 Monokai.tmTheme(或您正在使用的主题)。

    你必须找到包含<string>Tag attribute</string>的标签,并在dict后面添加这个section部分:

    <dict>
      <key>name</key>
      <string>Tag ng attribute</string>
      <key>scope</key>
      <string>entity.other.attribute-name.ng</string>
      <key>settings</key>
      <dict>
        <key>fontStyle</key>
        <string>bold</string>
        <key>foreground</key>
        <string>#FF6600</string>
      </dict>
    </dict>
    

    您保存文件,然后重新添加到您的“ZIP”,这是一个 sublime-package 文件夹。

    第 2 步:

    做同样的事情,但是对于你的HTML.tmLanguage,在HTML.sublime-package里面。

    在那里,你需要找到:

        <key>tag-generic-attribute</key>
    <dict>
        ...
    </dict>
    

    并在之后添加部分:

    <key>tag-ng-attribute</key>
    <dict>
        <key>match</key>
        <string>\b(ng-[a-zA-Z\-:]+)</string>
        <key>name</key>
        <string>entity.other.attribute-name.ng.html</string>
    </dict>
    

    再次保存,将其插入您的 sublime-package,然后瞧,删除 sublime 应用程序缓存,重新启动它,然后您就有了语法高亮。

    请告诉我结果。 我在这个链接中得到了这个解释: https://groups.google.com/forum/#!topic/angular/qCGSZ6a6KVA

    希望对你有帮助

    【讨论】:

    • HTML.tmLanguage 文件在哪里?
    【解决方案2】:

    对于 sublime 3,您必须编辑 HTML.sublime-syntax 文件:

    找到第 197 行“tag-id-attribute”和粘贴之前

    tag-ng-attribute:
    - match: \b(ng-[a-zA-Z\-:]+)
      captures:
        1: entity.other.attribute-name.ng.html
        2: punctuation.separator.key-value.html
    

    确保您没有标签。

    然后转到文件底部和“-include:tag-id-attribute”之后 粘贴:

    - include: tag-ng-attribute
    

    【讨论】:

    • 那行不通。它返回一个错误,指出语法不正确。
    猜你喜欢
    • 2021-09-27
    • 2016-11-04
    • 2016-09-29
    • 2013-07-10
    • 1970-01-01
    • 2014-05-28
    • 2017-04-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多