Visual Studio 代码行尾设置(行尾不一致的文件) [英] Visual studio code end of line setting (file with inconsistent line endings)
问题描述
是否可以在文件中保留原始行尾?(我使用visual studio code通过SAMBA在linux服务器上编辑文件)
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)
右下角有一个按钮可以选择LF或CRLF,但它替换了文件中的所有行尾.
There is a button at right bottom to choose either LF or CRLF, but it replace all the end of lines in the file.
示例:
line1 \r\n
line2 \r\n
line3 \n
推荐答案
否,在 VSCode 中不可能在整个文件中保留原始行尾.在内部,对于每个文件,VSCode 仅存储一个 _eol
值,并且当请求多行文本时,将其即时插入每一行之间.
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.
例如,参见 mirrorTextModel.ts.MirrorTextModel
是 ExtHostDocumentData
,它实现了 TextDocument
实体在 API 中公开.
See, for example, method getText()
in mirrorTextModel.ts. MirrorTextModel
is a base class of ExtHostDocumentData
, which implements the TextDocument
entity exposed in the API.
这篇关于Visual Studio 代码行尾设置(行尾不一致的文件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!