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

心已入冬 提交于 2019-12-10 16:30:56

问题


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:


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.



来源:https://stackoverflow.com/questions/45099741/visual-studio-code-end-of-line-setting-file-with-inconsistent-line-endings

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!