Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change EOL for all files from CLRF to LF in Visual Studio Code

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.

like image 851
Thong Yi Xuen Avatar asked Mar 12 '18 05:03

Thong Yi Xuen


People also ask

How do I change from CRLF to LF in VS Code for all files?

At 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.

How do I change my EoL in VS Code?

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.

How do I know if my file is LF or CRLF?

use a text editor like notepad++ that can help you with understanding the line ends. It will show you the line end formats used as either Unix(LF) or Macintosh(CR) or Windows(CR LF) on the task bar of the tool. you can also go to View->Show Symbol->Show End Of Line to display the line ends as LF/ CR LF/CR.

Should I use LF or CRLF?

Whereas Windows follows the original convention of a carriage return plus a line feed ( CRLF ) for line endings, operating systems like Linux and Mac use only the line feed ( LF ) character. The history of these two control characters dates back to the era of the typewriter.


2 Answers

Run these. It works for me. Customize it with your requirements

git config core.autocrlf false  git rm --cached -r .  git reset --hard 
like image 103
Brandon Truong Avatar answered Sep 28 '22 11:09

Brandon Truong


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.

like image 43
Woody Avatar answered Sep 28 '22 10:09

Woody