Sublime Text files with Unix line endings

Just setting "default_line_ending": "unix" is not enough, as this does not automatically convert Windows files.

import sublime_plugin

class SetUnixLineEndingsCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        self.view.set_line_endings("unix")


class SetLineEndings(sublime_plugin.EventListener):
    def on_pre_save(self, view):
        view.run_command("set_unix_line_endings")

In Sublime, choose Tools → Developer → New Plugin… . In the window that opens, delete everything in it and replace it with the program above. Click "Save" and the save file dialog should open in the Packages/User directory, the location of which varies by OS and installation type:
save the file as set_unix_line_endings.py and it will activate immediately.

The plugin only changes the line endings of the file if you edit the content and then save it. Just opening the file for viewing doesn't change anything.

If you no longer want the plugin to be active, just go into the Packages/User directory and delete the file or change its suffix to something other than .py - set_unix_line_endings.py.bak works fine for me.

close update prompt

First close the update prompt, add in Sublime settings:
"update_check": false

Guess you like

Origin blog.csdn.net/qq_38202733/article/details/131811350