How can I make all line endings (EOLs) in all files in Visual Studio Code, Unix-like?

Solution 1:

The accepted answer explains how to do this for all files (use files.eol in settings), but if you ever need to override that setting there's an indicator at the bottom right that you can click on and change for this one file. Took me a while to notice that this was clickable.

See CRLF in the message bar at the bottom right

Solution 2:

I searched for a simple solution for days and didn't have any success after I found some Git commands that changed all files from CRLF to LF.

As pointed out by Mats, make sure to commit changes before executing the following commands.

In the root folder type the following.

git config core.autocrlf false

git rm --cached -r .         # Don’t forget the dot at the end

git reset --hard

Solution 3:

In your project preferences, add/edit the following configuration option:

"files.eol": "\n"

This was added as of commit 639a3cb, so you would obviously need to be using a version after that commit.

Note: Even if you have a single CRLF in the file, the above setting will be ignored and the whole file will be converted to CRLF. You first need to convert all CRLF into LF before you can open it in Visual Studio Code.

See also: https://github.com/Microsoft/vscode/issues/2957

Solution 4:

You can find the option in Visual Studio Code settings. It's under "Text Editor"→"Files"→"Eol". Here you can select whether you want \n or \r\n or auto.

Enter image description here