Sublime Text 2 中怎样查找scope的名称

在Sublime Text 2中新增一个snippet时需要在配置文件中输入scope节点的值来限制snippet使用的语法范围(作用域),这个scope的值可以通过以下方法获得:
  1. 进入包所在目录,如果不知道目录位置,可以在编辑器内选“Preferences”-->“Browse Packages”菜单,在弹出的对话框里就能看到包所在路径:
  1. 进入对应的包内找到扩展名为“tmLanguage”的文件,打开它,从文件内查找“scopeName”这个串,找到后,紧跟其后的“string”节点内的值就是此语言对应的scope名称。
比如现在要找JSP语言对应的scope名称,那么进入包所在目录后再进入“Java”目录,这个目录里可以找到名为“Java Server Pages (JSP).tmLanguage”的文件,打开它查找“scopeName”这个串,你会看到以下内容:
那么由此可知“text.html.jsp”就是scope的名称了。
 
以下是部分scope名称列表:
 

语言(语法)

Scope名称

ActionScript

source.actionscript.2

ActionScript 3

source.actionscript.3

Ant

text.xml.ant

AppleScript

source.applescript

ASP

source.asp

Batch File

source.dosbatch

Bibtex

text.bibtex

C

source.c

C#

source.cs

C++

source.c++

camlp4

source.camlp4.ocaml

Clojure

source.clojure

CoffeeScript

source.coffee

CSS

source.css

D

source.d

Diff

source.diff

DOT

source.dot

Emmet

source.zen.5a454e6772616d6d6172

Erlang

source.erlang

Go

source.go

Groovy

source.groovy

Haskell

source.haskell

Hex

source.hex

HTML

text.html.basic

HTML (ASP)

text.html.asp

HTML (Erlang)

text.html.erlang.yaws

HTML (Rails)

text.html.ruby

HTML (Tcl)

text.html.tcl

HTML5

text.html.basic

Java

source.java

Java Server Pages (JSP)

text.html.jsp

JavaDoc

text.html.javadoc

JavaProperties

source.java-props

JavaScript

source.js

JavaScript (Rails)

source.js.rails

jQuery (JavaScript)

source.js.jquery

JSON

source.json

LaTeX

text.tex.latex

LaTeX Beamer

text.tex.latex.beamer

LaTeX Log

text.log.latex

LaTeX Memoir

text.tex.latex.memoir

Lisp

source.lisp

Literate Haskell

text.tex.latex.haskell

Lua

source.lua

Makefile

source.makefile

Markdown

text.html.markdown

Matlab

source.matlab

MultiMarkdown

text.html.markdown.multimarkdown

MXML

text.xml.mxml

NAnt Build File

source.nant-build

Objective-C

source.objc

Objective-C++

source.objc++

OCaml

source.ocaml

OCamllex

source.ocamllex

OCamlyacc

source.ocamlyacc

Perl

source.perl

PHP

source.php

Plain text

text.plain

Python

source.python

R

source.r

R Console

source.r-console

Rd (R Documentation)

text.tex.latex.rd

RegExp

source.regexp

Regular Expressions (Python)

source.regexp.python

reStructuredText

text.restructuredtext

Ruby

source.ruby

Ruby Haml

text.haml

Ruby on Rails

source.ruby.rails

Scala

source.scala

SFTP Output Panel

output.sftp

Shell Script (Bash)

source.shell

SQL

source.sql

SQL (Rails)

source.sql.ruby

Tasks

text.todo

Tcl

source.tcl

TeX

text.tex

TeX Math

text.tex.math

Textile

text.html.textile

XML

text.xml

XSL

text.xml.xsl

YAML

source.yaml

posted @ 2014-02-25 09:12  ahuing  阅读(226)  评论(0编辑  收藏  举报