Jam*_*ton 64 scope code-snippets sublimetext2
在尝试为Sublime Text 2编写自己的代码片段时,我遇到了以下两个问题:
查找范围键.我发现我可以逐个查看我的包,并找到对声明的"范围"属性的引用.例如在~/Library/Application Support/Sublime Text 2/Packages/JavaScript/Comments.tmPreferences(我的HTML包中的文件)中有以下两行:
<key>scope</key>
<string>source.js</string>
Run Code Online (Sandbox Code Playgroud)
因此,如果我希望我的当前代码段能够处理javascript文件,我将我的范围定义为:
<scope>source.js</scope>
Run Code Online (Sandbox Code Playgroud)
我假设所有这些范围键都是根据我安装的软件包即时定义的.Sublime Text是否在我可以更容易引用的任何地方构建列表?仔细阅读一堆包文件似乎过于繁琐.
定义多个范围属性.我已经想到了,以下行允许我的代码段在HTML和JavaScript文件中工作.
<scope>text.html, source.js</scope>
Run Code Online (Sandbox Code Playgroud)Bib*_*ath 145
以下是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
Run Code Online (Sandbox Code Playgroud)
如果遗漏了任何内容,请将其添加到此要点https://gist.github.com/4705378.
Jos*_*ght 76
使用此键盘快捷键:
Windows:ctrl+ shift+ alt+ p
Mac: ctrl + shift+p
当前范围将显示在Windows上状态栏的左侧,或显示在Mac上的弹出窗口中.
将这些用作文件中的<scope>密钥foo.sublime-snippet.
返回的作用域按特定列出.选择最佳"范围化"片段的范围,使其可用于制表符触发器.
有一个包叫做范围猎人,由艾萨克·缪斯,这是本真的很有帮助.
它可以显示文档中任何光标下的范围,我在调试自己的代码片段时发现它非常有用.有时它非常详细; 我最前面的文档中的示例范围:
Scope: text.tex.latex
meta.function.environment.list.latex
meta.function.environment.general.latex
meta.function.environment.math.latex
string.other.math.block.environment.latex
meta.group.braces.tex
meta.space-after-command.latex
Run Code Online (Sandbox Code Playgroud)
(为方便阅读而包装)
如果我花了一个星期的时间选择SL2,我就无法找到它,但是这个软件包可以在几秒钟内完成.强烈推荐.
这种详细程度还意味着您可以根据需要以非常精细的方式定义片段.例如,meta.function.environment.list.latex广泛对应于LaTeX中的列表,因此我有一个片段,\item当我在列表环境中按super + enter时插入一个新的,但没有其他人.我可以比盲目的猜测更有效地定位片段.
源代码在Github中,或者您可以通过Package Control安装它.
要回答#1,请查看语法的.tmLanguage文件,找到密钥:scopeName.这是语法用于代码段范围值的内容.
例如,来自nathos/sass-textmate-bundle的摘录
<key>scopeName</key>
<string>source.sass</string>
Run Code Online (Sandbox Code Playgroud)
所以你会source.sass在你的代码片段中使用.
以下是有关定义语法的更多信息
| 归档时间: |
|
| 查看次数: |
25042 次 |
| 最近记录: |