Sublime Forum

Restrictive scope in a snippet?

#1

I see the following line in the preferences:

"auto_complete_selector": "source - comment"

That means “scope = source, but not comment”. If I try to put this same thing in the <scope></scope> of a snippet, it doesn’t work. Does anyone know how to restrict a snippet this same way?

0 Likes

#2

@cwolves: did you found an answer and solution? Or more “advanced scoping for snippets” docs or hints, if any?

some docs I am grokking now, trying to find an answer:
https://www.sublimetext.com/docs/scope_naming.html
https://macromates.com/manual/en/scope_selectors

hm. This worked for me:

<scope>source.shell.bash - string</scope>

excludes strings well, and I see precence of “string.*” in scopes
(checking current scope with Ctrl+Shift+P (macOS) )

but this isn’t:

<scope>source.shell.bash - meta</scope>

this doesn’t excludes any meta even it’s present in the scope. Hm.

0 Likes

#3

meta is special and needs at least another sub scope to be treated. This is because modern syntaxes scope everything meta.something. Thus a selector such as - meta would exclude everything.

1 Like