How to disable ^M line endings in VSCode?

Viewed 7639

So VSCode has decided to start adding ^M characters to the end of any line I edit. They're not visible in the editor but git diff picks them up.

Weird line endings.

It wasn't doing this before, so I'm guessing I accidentally bumped some keyboard shortcut.

Does anyone know how to turn this off and have it just use regular line endings?

2 Answers

That's caused by the different standards used in line endings ("LineFeed" in linux and "CarriageReturn + LineFeed" in Windows).

You can set the encoding you want either by using the command palette (shift+crtl+p) and typing "end of line" (that's the mnemonic I use) until you find the command Change End of Line Sequence or by clicking the LF or CRLF button on the staus bar (near the bottom right corner).

You can then select LF or CRLF.

Go to Preferences and click on Settings. Than write LF in the search area. Next, click on "Files" under "Text Editor". You will see "Files: Eol". Eol means "End of line". In my case it was "auto", which means VSCode would use either LF or CRLF depending on the files.

The last step: change "auto" to "\n".

enter image description here

Note: this only applies to the new files.

Other solutions may be found here: How to change EOL for all files from CLRF to LF in Visual Studio Code

Related