58

in .tmTheme files the scope key defines how a element is highlighted:

    <dict>
        <key>name</key>
        <string>HTML: Attribute Values</string>
        <key>scope</key>
        <string>meta.tag string.quoted, meta.tag string.quoted constant.character.entity</string>
        <key>settings</key>
        <dict>
            <key>background</key>
            <string>#FFFFFF</string>
            <key>fontStyle</key>
            <string></string>
            <key>foreground</key>
            <string>#2aa198</string>
        </dict>
    </dict>

where can I find a list of all scopes supported by these apps, so I can create my own style?

Alex
  • 66,732
  • 177
  • 439
  • 641
  • Are you looking for the scopes defined by existing syntax definitions? I was under the impression that syntax scopes were just regex matches that are defined in each language's package. – bojolais May 31 '12 at 14:17
  • This question may help you : http://stackoverflow.com/questions/30153110/get-all-scope-names-on-sublime-text-3 – webNeat May 11 '15 at 15:21

7 Answers7

92

Copy/pasting (but converting HTML to Markdown) from the current version of the "Naming Conventions" section of the TextMate Language Grammar Guide:

  • comment — for comments.
    • line — line comments, we specialize further so that the type of comment start character(s) can be extracted from the scope.
      • double-slash// comment
      • double-dash-- comment
      • number-sign# comment
      • percentage% comment
      • character — other types of line comments.
    • block — multi-line comments like /* … */ and <!-- … -->.
      • documentation — embedded documentation.
  • constant — various forms of constants.
    • numeric — those which represent numbers, e.g. 42, 1.3f, 0x4AB1U.
    • character — those which represent characters, e.g. &lt;, \e, \031.
      • escape — escape sequences like \e would be constant.character.escape.
    • language — constants (generally) provided by the language which are “special” like true, false, nil, YES, NO, etc.
    • other — other constants, e.g. colors in CSS.
  • entity — an entity refers to a larger part of the document, for example a chapter, class, function, or tag. We do not scope the entire entity as entity.* (we use meta.* for that). But we do use entity.* for the “placeholders” in the larger entity, e.g. if the entity is a chapter, we would use entity.name.section for the chapter title.
    • name — we are naming the larger entity.
      • function — the name of a function.
      • type — the name of a type declaration or class.
      • tag — a tag name.
      • section — the name is the name of a section/heading.
    • other — other entities.
      • inherited-class — the superclass/baseclass name.
      • attribute-name — the name of an attribute (mainly in tags).
  • invalid — stuff which is “invalid”.
    • illegal — illegal, e.g. an ampersand or lower-than character in HTML (which is not part of an entity/tag).
    • deprecated — for deprecated stuff e.g. using an API function which is deprecated or using styling with strict HTML.
  • keyword — keywords (when these do not fall into the other groups).
    • control — mainly related to flow control like continue, while, return, etc.
    • operator — operators can either be textual (e.g. or) or be characters.
    • other — other keywords.
  • markup — this is for markup languages and generally applies to larger subsets of the text.
    • underline — underlined text.
      • link — this is for links, as a convenience this is derived from markup.underline so that if there is no theme rule which specifically targets markup.underline.link then it will inherit the underline style.
    • bold — bold text (text which is strong and similar should preferably be derived from this name).
    • heading — a section header. Optionally provide the heading level as the next element, for example markup.heading.2.html for <h2>…</h2> in HTML.
    • italic — italic text (text which is emphasized and similar should preferably be derived from this name).
    • list — list items.
      • numbered — numbered list items.
      • unnumbered — unnumbered list items.
    • quote — quoted (sometimes block quoted) text.
    • raw — text which is verbatim, e.g. code listings. Normally spell checking is disabled for markup.raw.
    • other — other markup constructs.
  • meta — the meta scope is generally used to markup larger parts of the document. For example the entire line which declares a function would be meta.function and the subsets would be storage.type, entity.name.function, variable.parameter etc. and only the latter would be styled. Sometimes the meta part of the scope will be used only to limit the more general element that is styled, most of the time meta scopes are however used in scope selectors for activation of bundle items. For example in Objective-C there is a meta scope for the interface declaration of a class and the implementation, allowing the same tab-triggers to expand differently, depending on context.
  • storage — things relating to “storage”.
    • type — the type of something, class, function, int, var, etc.
    • modifier — a storage modifier like static, final, abstract, etc.
  • string — strings.
    • quoted — quoted strings.
      • single — single quoted strings: 'foo'.
      • double — double quoted strings: "foo".
      • triple — triple quoted strings: """Python""".
      • other — other types of quoting: $'shell', %s{...}.
    • unquoted — for things like here-docs and here-strings.
    • interpolated — strings which are “evaluated”: date, $(pwd).
    • regexp — regular expressions: /(\w+)/.
    • other — other types of strings (should rarely be used).
  • support — things provided by a framework or library should be below support.
    • function — functions provided by the framework/library. For example NSLog in Objective-C is support.function.
    • class — when the framework/library provides classes.
    • type — types provided by the framework/library, this is probably only used for languages derived from C, which has typedef (and struct). Most other languages would introduce new types as classes.
    • constant — constants (magic values) provided by the framework/library.
    • variable — variables provided by the framework/library. For example NSApp in AppKit.
    • other — the above should be exhaustive, but for everything else use support.other.
  • variable — variables. Not all languages allow easy identification (and thus markup) of these.
    • parameter — when the variable is declared as the parameter.
    • language — reserved language variables like this, super, self, etc.
    • other — other variables, like $some_variables.
Phrogz
  • 296,393
  • 112
  • 651
  • 745
  • 5
    This answer actually answers the original question, should be accepted. – igauravsehrawat Feb 11 '16 at 11:30
  • Agreed that the main question is bests answered by this reply. Consider marking it as the preferred response. – juandesant Feb 24 '17 at 09:20
  • I wrote the current 'preferred' response, and I agree with the other commenters here. This answer should be marked as the preferred response, because it more completely answers the question as asked. – Chad Jun 17 '21 at 16:21
34

Edit: Phrogz's answer is better than my answer here, as it more accurately answers the question as asked. I recommend you check it out!


Unfortunately there doesn't seem to be any such comprehensive list.

However, if you press Shift+Ctrl+P in SublimeText 2, the status bar at the bottom of the screen will display a comprehensive list of all the scope keys that apply to the character immediately following your cursor position.

You can use this method to find the scope keys for anything you need from within SublimeText.

Update: Commenters Will and fregante below indicate this has changed for SublimeText 3.
For Windows/Linux, Shift+Ctrl+Alt+P is the appropriate command, and on a Mac the command is ⌘⌥P.

Chad
  • 472
  • 4
  • 4
14

There are a couple of sublime text packages you can use to do this.

Installing Package Control

Go to https://sublime.wbond.net/ and click "Installation" and follow the instructions to install sublime text package manager.

Packages Which Display the Current Scope

I know of a couple of sublime text packages which display the current scope in the status bar.

Installing One of the Above Packages

To install a package with sublime text package manager open sublime text's command palette (ctrl+shift+p) and choose the command Package Control: Install Package and then select one of the above packages.

Will
  • 7,225
  • 2
  • 23
  • 14
  • OT: thanks for ScopeAlways, BTW. I really love it, and recommend it on here whenever I get the chance. I do a lot of theming, and it's been invaluable for me :) – MattDMo Aug 22 '14 at 03:08
  • ScopeHunter was very helpful to me in making a Notepad++ colored theme. – pcunite Jul 14 '15 at 17:14
11

Scopes are from tmLanguage files which are different for each syntax. You can find a list of scope naming conventions at http://manual.macromates.com/en/language_grammars

atomi
  • 526
  • 3
  • 5
6

In addition to the excellent answers already posted, the Scopes Stats tab of TMTheme Editor displays a useful list of all the scopes in its 236 colour themes, with the most commonly-supported scopes at the top.

TachyonVortex
  • 8,242
  • 3
  • 48
  • 63
4

See a reference guide on the sublime site below:

Steve Tomlin
  • 3,391
  • 3
  • 31
  • 63
  • 1
    This is the correct answer now. Everyone should be encouraged to use these officially listed scopes for consistency. – user2664470 Oct 22 '16 at 20:24
3

Each syntax can name their own scopes, but they are based off of this list. For instance your syntax might specify that function is storage.type.function.js scope. If your theme supports that directly it will use that color, otherwise it will fallback to storage.type.function then storage.type then finally storage trying to find a color in your theme.

Since you are creating your own style, I would recommend installing ScopeStatus (CTRL+SHIFT+P, then Install Package, then ScopeStatus). Looking at a file using the syntax you want to concentrate on, do CTRL+SHIFT+P, then "Scope: Show in Status Bar". Now you can move the cursor to various elements to see what scope they give and you can use those to define colors.

You can check your themes to see what they do, go to "Preferences->Browse Packages" to open the folder where your packages are stored. I installed "Theme - Phoenix" which has a folder and a "Color Scheme" folder underneath. In one of the theme files I found 16 colors that were used for various scopes:

keyword.operator.class, constant.other, source.php.embedded.line
variable, support.other.variable, string.other.link, entity.name.tag, entity.other.attribute-name, meta.tag, declaration.tag
constant.numeric, constant.language, support.constant, constant.character, variable.parameter, punctuation.section.embedded, keyword.other.unit
entity.name.class, entity.name.type.class, support.type, support.class
string, constant.other.symbol, entity.other.inherited-class, markup.heading
keyword.operator, constant.other.color
entity.name.function, meta.function-call, support.function, keyword.other.special-method, meta.block-level
keyword, storage, storage.type, entity.name.tag.css
invalid
meta.separator
invalid.deprecated
markup.inserted.diff, markup.deleted.diff, meta.diff.header.to-file, meta.diff.header.from-file
markup.inserted.diff, meta.diff.header.to-file
markup.deleted.diff, meta.diff.header.from-file
meta.diff.header.from-file, meta.diff.header.to-file
meta.diff.range

Different themes might have different settings, for keyword.operator.class in the first group might have its own color or be the same as meta.diff.range.

Jason Goemaat
  • 28,692
  • 15
  • 86
  • 113