63

I have an autosetting for Windows somewhere (CRLF) which is really annoying, is there a way to change this to Unix?

2
  • 6
    Search for eol in the settings. There is a default setting there. Commented Feb 23, 2022 at 16:50
  • 2
    { "files.eol": "\n" } in settings.json Commented Aug 6, 2024 at 17:47

4 Answers 4

100
  • Open VSCode settings: Cmd / Ctrl + ,
  • Search for eol in settings and click on \n to make LF default.

enter image description here

Sign up to request clarification or add additional context in comments.

3 Comments

The title says Also modified elsewhere. Where is it?
@smwikipedia Hover the mouse pointer above the text "(Modified elsewhere)" and a popup will appear that states where the setting is modified.
The settings.json should now read: ` { "files.eol": "\n" } `
5

Open VS code window then Ctrl+Shift+P to open settings and search for EOL like @David Bakare suggested above.

1 Comment

How do you change this globally without having to go file by file?
5

Two things to do:

  1. To change all line endings from CRLF to LF on a Windows machine for a cloned repository. From the repository root folder, run:

    # Make sure you have committed any important local changes first git config core.autocrlf false git rm --cached -r . # Don’t forget the dot at the end git reset --hard git status 
  2. Using Windows-installed Github Desktop is not a good idea if using WSL. It seems there's quite a delay in reading between the Windows install and WSL files. So, it is better to just use source control features built into VSCode with the helpful WSL integration extension.

5 Comments

what is git reset --hard doing here?
@StephanKristyn It helped git not act like the new line endings where actual changes, iirc
Thanks... I think hard resets should never be done as a rule of thumb and as a best practice in any case as it rewrites your history and the history of everyone else if pushed to remote.
@StephanKristyn Understandable but no commit reference is being passed here so I'm not sure why it would be an issue in this case. I'll add a comment about committing any important local changes first though.
Thank you very much, this was the solution that really worked for me.
0

You can also set this on a path using a .gitattributes file

https://git-scm.com/docs/gitattributes

.devcontainer/.zshrc text eol=lf .devcontainer/.p10k.zsh eol=lf 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.