I had change the default EOL from CRLF to LF, but this only applies to the new files. I would like to know how to change the EOL for all the files at once as I have more than hundred of files and it will be hard to do it manually.
-
https://stackoverflow.com/a/39532890/45966 Has a solution that worked for me. – HellonearthisJun 25, 2018 at 17:09
-
1Does this answer your question? How can I make all line endings (EOLs) in all files in Visual Studio Code, Unix-like?– Gino MempinNov 17, 2021 at 3:07
3 Answers
Run these. It works for me. Customize it with your requirements
git config core.autocrlf false
git rm --cached -r .
git reset --hard
-
5in my opinion this is not the solution, if someone who uses unix enviroment will have the same end of line problems– GasparOct 9, 2019 at 2:35
To solve the problem in my project I used a Visual Studio Code extension called "Change All End Of Line Sequence", follow the process of the extension and then save all your files.
And that's it, hope it helps somebody still looking for a quick fix.
If you have a Node.js development environment and prettier
installed, one way of replacing all CRLF for LF is by running prettier --end-of-line lf --write
in the command line.
Another way is to set the endOfLine
option to lf
in the .prettierrc
configuration file and place a script in your package.json
like so:
...
"scripts": {
...
"format": "prettier --write"
...
}
...
Then, you just need to execute npm run format
in your terminal and all files targeted by prettier
in your project will be automatically changed and saved.