Visual studio code end of line setting (file with inconsistent line endings)

Viewed 708

Is it possible to keep original end of lines in the file? (I use visual studio code to edit files on a linux server through SAMBA)

There is a button at right bottom to choose either LF or CRLF, but it replace all the end of lines in the file.

example:

 line1 \r\n
 line2 \r\n
 line3 \n
1 Answers

No, it is not possible in VSCode to preserve the original line endings when they are not the same throughout a file. Internally, for each file, VSCode only stores a single _eol value, and when multi-line text is requested, inserts it between every line on the fly.

See, for example, method getText() in mirrorTextModel.ts. MirrorTextModel is a base class of ExtHostDocumentData, which implements the TextDocument entity exposed in the API.

Related