Sublime Forum

Snippet scope to specific file name?

#1

Hello sublimers,

Can I scope a snippet to a specific file name? I do some Java development and would like to add snippets that apply only to my Maven build files (pom.xml) and no other XML files.

Thanks,
cobro

0 Likes

#2

Yes, curious about this too

0 Likes

#3

Same need here as well. My use case is adding snippets for Python / pip requirements.txt files.

0 Likes

#4

In the general case, no; snippets are scoped via a scope and scopes are applied by syntax definitions.

So, in order to have files with specific names treated differently than others with regard to snippets, they would need to have a syntax applied to them that makes them distinct from other files with similar extensions and different names.

For example, all .txt files are considered Plain text files; so to do this with requirements.txt you would need some syntax that applies to this kind of file that makes it unique, plus a plugin that would know to apply this syntax to just this specifically named file.

Neither are impossible, but it’s also not available with out of the box functionality (in that the syntax and the plugin would both need to be created).

0 Likes