Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Sublime Text 2/3: Snippet scopes

Here is a list of scopes to use in Sublime Text 2/3 snippets -

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

Another list: http://stackoverflow.com/a/30170988/3872002

@vikjam

This comment has been minimized.

Copy link

@vikjam vikjam commented Apr 19, 2016

Perhaps PHP should include embedding.php? I'm guessing this based on the conversation here: sublimehq/Packages#24

Also, maybe it'd be worth adding Jade: text.jade.

@rafegoldberg

This comment has been minimized.

Copy link

@rafegoldberg rafegoldberg commented May 31, 2016

great list my man; and a serious 👍 for @vikjam's suggestion.

@fodra

This comment has been minimized.

Copy link

@fodra fodra commented Mar 22, 2017

love this. needed the markdown bit.

@code4cake

This comment has been minimized.

Copy link

@code4cake code4cake commented May 9, 2017

Possible to add different <scope>...<scope>s within one same file or one same line?

Right now I have this...

<snippet>
  <content><![CDATA[
import React, { Component } from 'react';

class $1 extends Component {
  render() {
    return (
      $2
    )
  } 
}

export default $1
]]></content>
  <!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
  <tabTrigger>react-class</tabTrigger>
  <!-- Optional: Set a scope to limit where the snippet will trigger -->
  <scope>source.js</scope>
  <scope>source.jsx</scope>
</snippet>

I would like my snippet to work both in files ending in js and jsx.

Thanks

@TimothyBramlett

This comment has been minimized.

Copy link

@TimothyBramlett TimothyBramlett commented May 16, 2017

Use commas to add multiple scopes.
Example:

<scope>source.c,source.cpp</scope>
@barbazzz

This comment has been minimized.

Copy link

@barbazzz barbazzz commented Sep 24, 2018

scss?

@dumpvn

This comment has been minimized.

Copy link

@dumpvn dumpvn commented Sep 26, 2018

fortran?

@johansenja

This comment has been minimized.

Copy link

@johansenja johansenja commented Jan 14, 2020

Typescript (fairly self explanatory):
<scope>source.tsx</scope> / <scope>source.ts</scope>

@mariovalney

This comment has been minimized.

Copy link

@mariovalney mariovalney commented Feb 10, 2020

For people from future:

You can now check all scopes here.
And don't forget to use Ctrl + Alt + Shift + P to show the current scope (or Tools > Developer > Show Scope Name).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.