c - 有没有办法在 Visual Studio 中为整个解决方案或项目将 EOL 设置为 LF?

标签 c visual-studio eol

在 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/

相关文章:

c - 如何在 C 中实现结构的 protected 访问修饰符

visual-studio - Visual Studio-DLL错误。

c - 结构成员标识符放在什么范围内?

c - 如何在 PCRE 中释放已编译的模式?

c++ - VS2013 中破坏的毕达哥拉斯三角恒等式规则

python - 当我重新启动 Tornado 服务器时,html 文件中的更改不会生效

svn - 如何避免 svn 存储库中的混合 eol 样式

c++ - 使用 std::ios_base::binary 有什么意义?

C:接收指向指针的指针的函数,因此它可以分配一个外部指针

.net - WInforms Combobox SelectionChangeCommitted 事件并不总是改变 SelectedValue