我可以根据文件类型设置 VS Code 默认 EOL 吗? [英] Can I set the VS Code default EOL based on file type?
问题描述
在 Windows 上使用 .sh
文件会导致在 Linux Docker 容器中运行它们时出现问题,如果它们具有 CRLF 的 EOL.我是否可以让 VS Code 始终使用 LF 处理特定文件类型,例如 .sh
,同时仍然对所有其他文件使用 CRLF?
Working with .sh
files on Windows causes issues when running them in Linux Docker containers if they have EOL of CRLF. Can I make VS Code always work with LF for specific file type such as .sh
while still using CRLF for all others?
我只在设置中找到 "files.eol": "\r\n"
,但这是全局的.
I only find "files.eol": "\r\n"
in settings, but this is global.
我知道您可以在每个文件的基础上在底部工具栏中更改此设置,但我希望这是所有 .sh
文件的默认设置.
I understand you can change this in the bottom toolbar on a per-file basis, but I would like this to be the default for all .sh
files.
推荐答案
您可以使用 EditorConfig.
安装editorconfig扩展,然后添加.editorconfig
项目根目录下的文件:
Install the editorconfig extension, and then add a .editorconfig
file at the root of your project with this:
[*]
end_of_line = crlf
[*.{sh}]
end_of_line = lf
但正如@axiac 所说,我建议始终使用 lf
...
But as @axiac said, I would recommend to always use lf
...
这篇关于我可以根据文件类型设置 VS Code 默认 EOL 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!