How to fix the Inconsistent Line Endings Warning message in Unity and Visual Studio 2019

 A few months ago I decided to upgrade to Visual Studio 2019. When using Unity together with Visual Studio a warning message started to appear: 

There are inconsistent line endings in the 'Assets/name-of-script.cs' script. Some are Mac OS X (UNIX) and some are Windows. This might lead to incorrect line numbers in stacktraces and compiler errors. Many text editors can fix this using Convert Line Endings menu commands. 

If you Google the problem, people tell you to download Strip'em for Visual Studio. I had Strip'em installed on the older version of Visual Studio, which is why the warning message never appeared then. So when I tried to download Strip'em for VS 2019, I couldn't because only VS 2017 and earlier are supported by Strip'em. 

To solve this problem in VS 2019 and later versions, you have to go to the script giving you the warning. In the bottom-right corner of the script, you see a box called MIXED, meaning that your line endings are mixed. 

If you click on the box, you can chose between:

  • CRLF - Windows
  • LF - Unix
  • CR - old MacOS ( pre-OSX Macintosh)
To figure out which line ending you should use you have to go to the Unity Editor. Click on Project Settings → Editor → Line Endings For New Scripts. Here you can set the Mode to Unix, Windows, or OS Native. 

I think Unix is default, meaning the little box in the bottom-right corner of VS should be set to LF. Now the warning message should have disappeared. Win!