Reputation: 2342
VS Code 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.
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?
Upvotes: 49
Views: 35486
Reputation: 626
That's caused by the different standards used in line endings (LineFeed
or LF
in Linux and CarriageReturn
+ LineFeed
or CRLF
in Windows).
You can set the encoding you want by either of the following ways:
Click the LF or CRLF button on the status bar (near the bottom right corner), then select LF or CRLF.
Go to the command palette (SHIFT+CTRL+p) and type "end of line" (that's the mnemonic I use) until you find the command Change End of Line Sequence.
Upvotes: 51
Reputation: 706
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".
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
Upvotes: 10