In Sublime Text (3), I can select the dictionary to use for spell checking. However, this setting seems to be global rather than on a per-file basis. This is annoying when I'm working on multiple files that use different languages. How can I achieve that Sublime Text remembers what dictionary to use for a file?
Usually it is needed to set settings based on the syntax of the file (one dictonary for javascript files, another for css files, etc.). You can achieve this goal easily using syntax specific settings. But there are also times where you need file-specific settings (files with the same syntax with different settings values). I give you example solutions for both cases.
File-specific way
In order to set view-specific settings (similar to file-specific) you can write a plugin. This simple example shows an input panel in which you can set the desired dictionary for the opened file.
Save it as example.py inside Packages>User. Then add a key-binding and trigger it when you're focused in the desired view:
Note that this is view-specific, so if you close sublime and then re-open it the setting is restored, but if you close the file tab the setting is lost, so if you open the file in the future you'll have to set the setting again. To add a real file-specific setting you need a more complex plugin that extends EventListener and reads the files names in order to set the syntax.
Syntax-specific way
In addition to default settings and user settings you can use syntax speific settings.
Lets say you want to set the dictonary for javascript files, to add the required syntax specific settings open a javascript source file, then go to menu
Preferences>Settings-more>Syntax-specific-user
, and in the file opened set the settings:Finally save it and now your javascript files are using the specified dictonary. Repeat the proccess for other file types.
Note that this is not file-specific but syntax-specific, so if you really need different dictionaries for different javascript files (for example) you'll need to use the other way.