Skip to content
Talk to an engineerRequest access

Scopes

The standard scope names the built-in grammars use and the built-in themes style, and the VS Code scopes each one is read from.

A scope names what a piece of code is. The standard ones are constants on Scopes:

Standard scope names used by the built-in grammars and themes.

Scopes are plain dotted strings, so grammars may use any name. A theme resolves a.b.c by trying a.b.c, then a.b, then a, so a custom scope such as keyword.control.flow still picks up the keyword style.

Constant Scope Meaning From VS Code theme scopes
Scopes.comment comment A comment. comment
Scopes.commentDoc comment.doc A documentation comment. comment.block.documentation, comment
Scopes.string string A string literal, including its delimiters. string
Scopes.stringEscape string.escape An escape sequence inside a string, such as \n. constant.character.escape
Scopes.interpolation interpolation An interpolated expression inside a string, such as ${x}. meta.embedded, punctuation.definition.template-expression
Scopes.number number A numeric literal. constant.numeric
Scopes.keyword keyword A reserved word. keyword.control, keyword, storage.type, storage.modifier, storage
Scopes.literal literal A literal constant such as true, false or null. constant.language
Scopes.type type A type name. entity.name.type, entity.name.class, support.class
Scopes.typeBuiltin type.builtin A type provided by the language or its core library. support.type, storage.type
Scopes.function function A function or method name. entity.name.function, support.function, meta.function-call
Scopes.variable variable A variable reference, such as $HOME in a shell script. variable
Scopes.variableLanguage variable.language A language-defined variable such as this or super. variable.language
Scopes.meta meta Metadata such as annotations, attributes or preprocessor directives. meta.decorator, meta.annotation, entity.name.function.decorator, meta.preprocessor, keyword.control.directive
Scopes.property property A property or object key. support.type.property-name, meta.object-literal.key, variable.other.property
Scopes.punctuation punctuation Punctuation such as brackets and separators. punctuation
Scopes.operator operator An operator. keyword.operator
Scopes.tag tag A markup tag name. entity.name.tag
Scopes.attribute attribute A markup attribute name. entity.other.attribute-name
Scopes.regexp regexp A regular expression literal. string.regexp
Scopes.heading heading A document heading. markup.heading
Scopes.emphasis emphasis Emphasized (italic) text. markup.italic
Scopes.strong strong Strong (bold) text. markup.bold
Scopes.link link A link or URL. markup.underline.link, string.other.link
Scopes.code code Inline or block code inside prose. markup.inline.raw, markup.raw
Scopes.quote quote A quotation. markup.quote
Scopes.addition addition An added line in a diff. markup.inserted
Scopes.deletion deletion A removed line in a diff. markup.deleted
Scopes.invalid invalid Invalid or illegal syntax. invalid

The last column is used by ValTheme.fromVsCode: for each scope, the style of the first of those TextMate scopes the VS Code theme defines.

A token carries a stack of scopes, such as string > interpolation, and its style is the styles of its stack merged from the outside in. A theme looks a dotted scope up from the most specific name to the least: comment.doc uses the theme’s comment.doc style if it has one, and comment otherwise. So a grammar can introduce a scope such as keyword.control.flow, and every theme still styles it as a keyword.

In HTML output, a dotted scope becomes one class per level: comment.doc is vh-comment vh-comment-doc.

For editor queries, scopes starting with string, regexp or comment are strings or comments, and an interpolation inside a string is code again.