Visual Studio 代码行尾设置(行尾不一致的文件) [英] Visual studio code end of line setting (file with inconsistent line endings)

查看:89
本文介绍了Visual Studio 代码行尾设置(行尾不一致的文件)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在文件中保留原始行尾?(我使用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.MirrorTextModelExtHostDocumentData,它实现了 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆