Fixing Sublime Text 2 line endings?

后端 未结 4 1935
庸人自扰
庸人自扰 2020-11-27 10:57

Here is my Settings - User config:

{
    \"auto_indent\": true,
    \"color_scheme\": \"Packages/Color Scheme - Default/Twilight.tmTheme\",
             


        
4条回答
  •  我在风中等你
    2020-11-27 11:22

    The EditorConfig project (Github link) is another very viable solution. Similar to sftp-config.json and .sublime-project/workspace sort of file, once you set up a .editorconfig file, either in project folder or in a parent folder, every time you save a file within that directory structure the plugin will automatically apply the settings in the dot file and automate a few different things for you. Some of which are saving Unix-style line endings, adding end-of-file newline, removing whitespace, and adjusting your indent tab/space settings.


    QUICK EXAMPLE

    Install the EditorConfig plugin in Sublime using Package Control; then place a file named .editorconfig in a parent directory (even your home or the root if you like), with the following content:

    [*]
    end_of_line = lf
    

    That's it. This setting will automatically apply Unix-style line endings whenever you save a file within that directory structure. You can do more cool stuff, ex. trim unwanted trailing white-spaces or add a trailing newline at the end of each file. For more detail, refer to the example file at https://github.com/sindresorhus/editorconfig-sublime, that is:

    # editorconfig.org
    root = true
    
    [*]
    indent_style = tab
    end_of_line = lf
    charset = utf-8
    trim_trailing_whitespace = true
    insert_final_newline = true
    
    [*.md]
    trim_trailing_whitespace = false
    

    The root = true line means that EditorConfig won't look for other .editorconfig files in the upper levels of the directory structure.

提交回复
热议问题