Skip to content

Instantly share code, notes, and snippets.

@J2TEAM
Forked from iambibhas/scopes.txt
Last active January 17, 2024 22:44
Show Gist options
  • Save J2TEAM/a54bafb082f90c0f20c9 to your computer and use it in GitHub Desktop.
Save J2TEAM/a54bafb082f90c0f20c9 to your computer and use it in GitHub Desktop.
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

@code4cake
Copy link

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
Copy link

Use commas to add multiple scopes.
Example:

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

@barbazzz
Copy link

scss?

@dumpvn
Copy link

dumpvn commented Sep 26, 2018

fortran?

@johansenja
Copy link

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

@mariovalney
Copy link

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).

@Clivern
Copy link

Clivern commented Oct 26, 2020

Rust: source.rust

@dreig
Copy link

dreig commented Oct 25, 2021

Thank you @mariovalney! You're a life saver.
I knew about the existence of this list and I still couldn't find it for the longest time.
I wanted to add a Sublime Snippet that works only works in *.sublime-project files. It turns out that the scope is source.json.sublime.
Now hopefully I don't forget about Ctrl + Alt + Shift + P the next time I need it in a year or so... 😕

@vivek1986
Copy link

vivek1986 commented Jan 17, 2024

Great list and updates y'all, but as there's always room for improvement, how about any possibility of using wildcard characters that would match all scopes or situation where scoping cannot be defined like edit-in-progress / unsaved text file ? Does something like source.* or text.* works inside scope tags to cover all scopes ? I think that would be a great next level if it's already there or somehow possible, right ?

For example when I am doing some long typing, and I type st-st and hit Tab, it would translate to step-by-step and such cases...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment