Hello!
I want my files in ‘.xxx’ format (with ‘xxx’ syntax and special folder for ‘xxx’ language) to be opened in certain encoding (Windows 866) each time, when I open it. But I dont want to change fallback encoding in global settings, because other project has UTF-8 encoding. Can I change encoding settings only for one file format or syntax?
Special encoding for certain file format (syntax)
Crasher
#1
0 Likes
skuroda
#3
There’s probably a plugin to do something like this already, but I don’t know what it is. Anyways, you would probably use create an event listener and define an “on_load(view)” method. You can use “view.file_name()” to get the name of the file. From that you can parse the extension. You can then use “view.set_encoding(encoding)” to set the encoding for that particular view.
You could also create a syntax specific setting “Preferences -> Settings - More -> Syntax Specific - User”. Then create a “default_encoding” entry like you would normally. This should apply this encoding only for this syntax, leaving the default to whatever you currently have it as.
0 Likes