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

本文详细介绍了如何在SublimeText2中为JSP snippet设置scope,包括查找scope名称的方法和步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值