如何在类 Unix 的 Visual Studio Code 中的所有文件中制作所有行结尾(EOL)? [英] How can I make all line endings (EOLs) in all files in Visual Studio Code, Unix-like?

查看:27
本文介绍了如何在类 Unix 的 Visual Studio Code 中的所有文件中制作所有行结尾(EOL)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Windows 10 Home 并且我通常使用 Visual Studio Code (VS Code)编辑 Linux Bash 脚本以及 PHP 和 JavaScript.

I use Windows 10 Home and I usually use Visual Studio Code (VS Code) to edit Linux Bash scripts as well as PHP and JavaScript.

我没有为 Windows 开发任何专门的东西,我不介意我编辑的所有文件的默认 EOL 将是 Unix 之类的 (nix).

I don't develop anything dedicated for Windows and I wouldn't mind that the default EOLs for all files I edit whatsoever would be Unix like (nix).

在 Visual Studio Code 中,我如何确保所有文件(无论文件扩展名)中的所有 EOL 都是 nix?

How could I ensure that all EOLs, in all files whatsoever (from whatever file extension), are nix, in Visual Studio Code?

我在 Windows 中使用 Visual Studio Code 编写了一些 Bash 脚本,并将它们作为项目的一部分上传到 GitHub,并且一位审查该项目的高级程序员告诉我我有 Windows EOL 之后,我问了这个问题 还有一个我可以解决的 BOM 问题如果我将 EOL 更改为 nix(或者至少我是这么理解的).

I ask this question after I've written a few Bash scripts in Windows with Visual Studio Code, uploaded them to GitHub as part of a project, and a senior programmer that reviewed the project told me I have Windows EOLs there and also a BOM problem that I could solve if I'll change the EOLs there to be nix (or that's what I understood, at least).

因为我的所有开发都是面向 Linux 的,所以我更喜欢默认情况下,任何我编辑的文件都会有 nix EOL,即使它是 Windows 独有的.

Because all my development is Linux-oriented, I would prefer that by default, any file I edit would have nix EOLs, even if it's Windows unique.

推荐答案

在您的项目首选项中,添加/编辑以下配置选项:

In your project preferences, add/edit the following configuration option:

"files.eol": "\n"

这是在提交 639a3cb 时添加的,因此您显然需要使用提交之后的一个版本.

This was added as of commit 639a3cb, so you would obviously need to be using a version after that commit.

注意:即使文件中只有一个CRLF,上面的设置也会被忽略,整个文件将被转换为CRLF.您首先需要将所有 CRLF 转换为 LF ,然后才能在 Visual Studio Code 中打开它.

Note: Even if you have a single CRLF in the file, the above setting will be ignored and the whole file will be converted to CRLF. You first need to convert all CRLF into LF before you can open it in Visual Studio Code.

另见:https://github.com/Microsoft/vscode/issues/2957

这篇关于如何在类 Unix 的 Visual Studio Code 中的所有文件中制作所有行结尾(EOL)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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