is there a way to set default encoding (windows/unix/etc)? and for a specific language?
Text encoding
After digging a bit, i found the relevant sublime command is
‘setLineEnding type’, where type is ‘unix|windows|mac’
Now I need to know if there is a way to set to default for new files, and if it can be done to a specific file type.
Help will be appreciated
oh, thanks, great example. i did few changes:
[code]import sublime, sublimeplugin
LE_DEFAULTS = {u’Packages/Erlang/Erlang.tmLanguage’:‘unix’}
class DefaultLineEndingCommand(sublimeplugin.Plugin):
def onPreSave(self, view):
# get current syntax language
syntax = view.options().get(‘syntax’)
# search if current syntax has a default line ending defined
le = LE_DEFAULTS.get(syntax)
# set the line ending if found a definition
if le:
view.runCommand(‘setLineEnding’, [le])
[/code]
the problem is, i wanted it to be invoked on new erlang files. the problem is that if i use onNew, the syntax is not yet set. and if i use onPreSave (as above) i can’t manually override it, i.e. if i want to change it and set the line ending manually this plugin wil always override it when i save the file. what i really wanted is onSyntaxChange event…