Last updated: Apr 6, 2024
Reading time·4 min

To change the end of line sequence for a specific file:

If you don't see the CRLF or LF label in the status bar at the bottom,
right-click on the status bar and make sure "Editor End of Line" is ticked.

An alternative way to set the end of line sequence is to use the Command Palette.
Ctrl + Shift + P on Windows and Linux.Command + Shift + P on macOS.F1 to open the Command Palette.

This allows you to set the line endings for the file.
If you want to change the default value of the end of line sequence globally:
Ctrl + Shift + P (or Command + Shift + P on macOS).F1 to open the Command Palette.
You can also open the settings screen by pressing Ctrl + , on Windows and
Linux or Cmd + , on macOS.

The Files: Eol setting has 3 possible values:
auto - uses operating system-specific end of line character.\n - uses LF (LineFeed) character. Suitable for macOS and Linux.\r\n - uses CRLF (CarriageReturn + LineFeed) characters. Suitable for
Windows.Note that updating the setting globally only changes the default line ending character for newly created files.
It won't change the line endings for your existing files.
If you only want to apply the setting to your current project:
In the root directory of your project, create a .vscode folder.
Create a settings.json file in the .vscode folder.
Set the files.eol property in your
settings.json file.
{ "files.eol": "\n" }

The possible values are: \n, \r\n and auto.
{ "files.eol": "\r\n" }
And here is an example that sets the property to auto (operating
system-specific end of line character).
{ "files.eol": "auto" }
Updating the files.eol setting in .vscode/settings.json only applies to your
current project (workspace) and overrides any global configuration of the
property.
As previously noted, the setting only changes the default line ending for newly created files.
It won't change the line endings for your existing files.
VS Code doesn't have a native way to show line endings on each line, however, you can use an extension.
Ctrl + Shift + X on Windows or Linux.Command + Shift + X on macOS.
Make sure to install the correct Render Line Endings extension as shown in the screenshot.
Ctrl + Shift + P (or Command + Shift + P on macOS).F1 to open the Command Palette.Type user settings json.
Click on Preferences: Open User Settings (JSON)

settings.json file.{ "editor.renderWhitespace": "trailing", "code-eol.newlineCharacter": "↓", "code-eol.returnCharacter": "←", "code-eol.crlfCharacter": "↵", // your other settings }
You can also set the renderWhitespace property to all to render all
whitespace characters.
When you open a file, you will be able to see the EOL characters at the end of each line.

If you need to change the EOL character for all files from CRLF (Windows) to LF (macOS and Linux):
autocrlf to false by issuing the following command.git config core.autocrlf false
git rm --cached -r .
git reset --hard
If you use prettier in your environment, you can also issue a command to change the EOL character for all files from CRLF to LF.
npx prettier --end-of-line lf --write
You can also set the endOfLine option to lf in your .prettierrc file.
"endOfLine": "lf"
Now when you issue the npx prettier --write command, it automatically converts
the EOL character for all files from CRLF to LF.
npx prettier --write
I've also written a guide on how to use VS Code as your default Git editor, difftool and mergetool.
You can learn more about the related topics by checking out the following tutorials: