Search code examples
giteditornewlinecode-editor

Is it ok to paste snippits of code eg from a browser window if git is set to have core.autocrlf false?


I am researching the best autocrlf setting for GIT and I am confused about what happens with code pasted into the editor if it is set to false. I notice many people recommend setting it to false, mentioning that as long as proper and properly set editors are used then there should be no problems, and I can understand this if I write ALL the code in the file; but I am confused about how this setting would work if I copy a snippit from eg a browser, or maybe some old code or something, or what if i used an entire old file. Surely I could easily end up with mixed CRLF and LF's as some of the code I get might be CRLF and some LF? Or are editors so smart that they themselves convert any pasted in code on save?

EDIT:I suppose I should also be asking: Is it a real problem if the EOF's are mixed?


Solution

  • The idea is, in order to avoid any issue with EOF, to use only editors:

    • able to detect the current EOF style used by the opened file
    • able to save that file with the same EOF style (so, no conversion on save)

    That way: