在 Visual Studio 中,您可以将文件的 EOL 设置为 CRLF、LF 或 CR,但是您只能对单个文件执行此操作。我正在寻找一种方法来确保我的解决方案中创建的每个新文件都会自动使用 LF。有任何想法吗?提前致谢!
最佳答案
添加 .editorconfig
项目(或解决方案)的根目录中具有以下条目的文件应将行尾设置为 LF
默认情况下(对于新添加的行,请参阅下面的注释)。
[*]
end_of_line = lf
引自 Create portable, custom editor settings with EditorConfig页。You can add an EditorConfig file to your project or codebase to enforce consistent coding styles for everyone that works in the codebase.
The editor in Visual Studio supports the core set of EditorConfig properties:
[...]end_of_line
When you add an .editorconfig file to a folder in your file hierarchy, its settings apply to all applicable files at that level and below.
When you add an EditorConfig file to your project in Visual Studio, new lines of code are formatted according to the EditorConfig settings. The formatting of existing code is not changed unless you run one of the following commands:
Code Cleanup (Ctrl+K, Ctrl+E), which applies any white space settings, such as indent style, and selected code style settings, such as how to sort using directives.
Edit > Advanced > Format Document (or Ctrl+K, Ctrl+D in the default profile), which only applies white space settings, such as indent style. Note
关于c - 有没有办法在 Visual Studio 中为整个解决方案或项目将 EOL 设置为 LF?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63656466/