Sublime Forum

How to configure Sublime Text 3 editor settings for specific file extensions?

#1

I want to change some editor settings that’s only applicable to certain file extensions. File extensions could be something I just made up (example: .mrjayviper file extension)

I cannot find a guide/page on what file name to use for different file types/extensions. Like in the main/default settings file, an example was given for Python files which is to use Packages/User/Python.sublime-settings.

Thanks!

0 Likes

#2

Configuration settings are set globally, per syntax, per project and per open file. However settings are based on the type of the file, not the extension that they have.

For example, there’s a Python.sublime-syntax file that knows how to syntax highlight Python, and it includes information that .py is the extension for Python files. Sublime uses the extension to know that the file is a Python file to apply the syntax, and then the settings associated with the file type come from Python.sublime-settings because that file shares the same name as the syntax.

So, generally speaking you can’t apply specific settings to something.bob just because it has an extension of .bob unless that’s a known file type of some sort without some extra work being involved.

One way would be to create a syntax definition (even if it contains no useful rules) to make the association, or another would be a plugin that applies settings for you on file load.

I’m not aware of anything that does that already, though. Most questions of this nature are about how to get Sublime to recognize various file extensions as the appropriate type.

2 Likes