I use Windows 10 Home and I usually use Visual Studio Code (VS Code) to edit Linux Bash scripts as well as PHP and JavaScript.
I don't develop anything dedicated for Windows and I wouldn't mind that the default EOLs for all files I edit whatsoever would be Unix like (nix).
How could I ensure that all EOLs, in all files whatsoever (from whatever file extension), are nix, in Visual Studio Code?
I ask this question after I've written a few Bash scripts in Windows with Visual Studio Code, uploaded them to GitHub as part of a project, and a senior programmer that reviewed the project told me I have Windows EOLs there and also a BOM problem that I could solve if I'll change the EOLs there to be nix (or that's what I understood, at least).
Because all my development is Linux-oriented, I would prefer that by default, any file I edit would have nix EOLs, even if it's Windows unique.
VS Code => Settings => Files: EoL And choose “\n” as EoL character if you would like your files to have Unix Style line endings and choose “\r\n” if you would like your files to have Windows Style line endings. VS Code — Eol Settings for Files. That settings applies to all new files that you create.
The Quick FixAt the bottom right of the screen in VS Code there is a little button that says “LF” or “CRLF”: Click that button and change it to your preference. Voila, the file you are editing now has the correct line breaks.
The Quick Fix for “End of line character is invalid” At the bottom right of the screen in VS Code, click the little button that says LF or CRLF . After changing it to your preference, Voila, the file you're editing now has the correct line breaks.
Go to Project> Solution Options> Source Code> Code Formatting> Text File In the Line Terminations drop box select Unix/Mac. Show activity on this post. The LF is clickable and you choose either LF or CRLF. Pretty sure that visual studio code, not visual studio.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With