CJ Dennis
CJ Dennis

Reputation: 4356

Change the line endings in Visual Studio 2017 for Mac

How do I change the line endings of all source files in an existing project in Visual Studio 2017 for Mac?

I have cloned a Git project where a few of the files have mixed line endings. The vast majority of the source files use Unix line endings (\n). I used a regex search and replace to find all \u2028 (LINE SEPARATOR) characters and replace them with \n, but I'm wondering if there's a way to normalise the line endings in a simpler way.

The problem these supported but non-standard line endings have is that Git doesn't recognise them, causing multiple lines to be marked as changed, when only a single line has really been changed.

I have seen some line ending answers for the Windows version of Visual Studio 2017, but the Mac version is quite different, so the answers weren't applicable.

Upvotes: 3

Views: 7131

Answers (1)

ow3n
ow3n

Reputation: 6617

You can change how you save individual files in Visual Studio for Mac

  1. Go to Visual Studio > Preferences
  2. In the dialog box that appears scroll the left menu down to the Text Editor section and select General.
  3. In the first option, Line ending conversion, change Leave line endings as is to Always convert line endings.

screenshot of dialog

Upvotes: 6

Related Questions