scope - 定义自定义 Sublime Text 2 片段的范围

标签 scope sublimetext2 code-snippets

在尝试为 Sublime Text 2 编写自己的代码片段时,我遇到了以下两个问题:

  1. 查找范围键。我发现我可以一一查看我的包并找到对声明的“范围”属性的引用。例如,在 ~/Library/Application Support/Sublime Text 2/Packages/JavaScript/Comments.tmPreferences (我的 HTML 包中的文件)中有以下两行:

    <key>scope</key>
    <string>source.js</string>
    

    因此,如果我希望当前的代码片段能够处理 javascript 文件,我可以将范围定义为:

    <scope>source.js</scope>
    

    我假设所有这些范围键都是根据我安装的软件包动态定义的。 Sublime Text 是否会在我可以更轻松引用的任何地方构建一个列表?仔细阅读一堆包文件似乎过于乏味。

  2. 定义多个范围属性。我已经弄清楚了这一点,下面的行允许我的代码片段在 HTML 和 JavaScript 文件中工作。

    <scope>text.html, source.js</scope>
    

最佳答案

这里是 Sublime Text 2 代码片段中使用的范围列表 -

ActionScript: source.actionscript.2
AppleScript: source.applescript
ASP: source.asp
Batch FIle: source.dosbatch
C#: source.cs
C++: source.c++
Clojure: source.clojure
CoffeeScript: source.coffee
CSS: source.css
D: source.d
Diff: source.diff
Erlang: source.erlang
Go: source.go
GraphViz: source.dot
Groovy: source.groovy
Haskell: source.haskell
HTML: text.html(.basic)
JSP: text.html.jsp
Java: source.java
Java Properties: source.java-props
Java Doc: text.html.javadoc
JSON: source.json
Javascript: source.js
BibTex: source.bibtex
Latex Log: text.log.latex
Latex Memoir: text.tex.latex.memoir
Latex: text.tex.latex
LESS: source.css.less
TeX: text.tex
Lisp: source.lisp
Lua: source.lua
MakeFile: source.makefile
Markdown: text.html.markdown
Multi Markdown: text.html.markdown.multimarkdown
Matlab: source.matlab
Objective-C: source.objc
Objective-C++: source.objc++
OCaml campl4: source.camlp4.ocaml
OCaml: source.ocaml
OCamllex: source.ocamllex
Perl: source.perl
PHP: source.php
Regular Expression(python): source.regexp.python
Python: source.python
R Console: source.r-console
R: source.r
Ruby on Rails: source.ruby.rails
Ruby HAML: text.haml
SQL(Ruby): source.sql.ruby
Regular Expression: source.regexp
RestructuredText: text.restructuredtext
Ruby: source.ruby
SASS: source.sass
Scala: source.scala
Shell Script: source.shell
SQL: source.sql
Stylus: source.stylus
TCL: source.tcl
HTML(TCL): text.html.tcl
Plain text: text.plain
Textile: text.html.textile
XML: text.xml
XSL: text.xml.xsl
YAML: source.yaml

如果缺少任何内容,请将其添加到此要点中 https://gist.github.com/4705378 .

关于scope - 定义自定义 Sublime Text 2 片段的范围,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13922174/

相关文章:

php - 在集合 laravel 中使用查询范围

python - 全局变量在模块级别未定义

jQuery 回调范围

sublimetext2 - 在 sublime text 2 中快速添加上一个

build - 将指定的构建系统设置为 sublime text 2 上文件类型的默认值

sorting - SublimeText - 按字母顺序对 json 列表进行排序

visual-studio-code - VScode 中的 'Javascript Language Basic' 配置在哪里?

javascript - 在文本区域内添加 Javascript 片段

javascript - 使用 jQuery 拖动和排序 div 并输出 html 代码

javascript - 访问回调内函数的局部变量