Search Unity

Stop line ending issues with VS2019 Community

Discussion in 'Code Editors & IDEs' started by andyz, Jan 7, 2020.

  1. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,279
    VS community used to have better line ending support in 2017 I think, particularly with Line Endings Unifier added,
    but with 2019 I see no option to set line endings and so I think it uses windows (on windows) style by default which I would rather avoid and set linux everywhere to avoid conflicts, however is there no other option?

    Too often I get inconsistent line ending warnings from Unity
     
  2. sailro

    sailro

    Microsoft

    Joined:
    Jul 30, 2014
    Posts:
    167
    Hello,

    There are several ways to do that. The best is probably to use an .editorconfig file, given it is now fully supported with VS2019 and setup end_of_line depending on the file extension.

    If you are using git, I would also recommend to create a .gitattributes file to enforce rules with your git repo and to properly setup your git settings like core.autocrlf regarding auto-end-of-line transformations, so that everything is playing nicely between your IDE, your repo and your PR/review workflow.

    Demo config I'm using to share a repo on my Mac and on my Window machines: (so that i'm using LF on Mac for cs files and CRLF on Windows thanks to git core.autocrlf):


    >> git settings: >>>>>>>>>>>>>>>>>>>>>>

    core.autocrlf=true
    core.ignorecase=true

    >> .gitattributes file >>>>>>>>>>>>>>>>>

    * text=auto

    .md text
    .cs text

    .sln text=crlf
    .*proj text=crlf
    .settings text=crlf

    >> .editorconfig file >>>>>>>>>>>>>>>>>>

    [*]
    insert_final_newline = true
    indent_style = space
    indent_size = 4

    [*.sh]
    end_of_line = lf

    [*.{cmd, bat}]
    end_of_line = crlf
     
  3. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,279
    ok thanks, though repo not git.
    So there is no in-editor setting to enable for line ending format enforcement?
    I know this is a much wished for feature - thus the Line Endings Unifier extension was born