runliuv

runliuv@cnblogs

  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 :: 管理 ::

trea 默认utf-8-bom,.editorconfig

C# .NET,用trea 改 .cs 或*.cshtml 文件时,trea 经常把文件改成 utf-8 无BOM的。

解决方法:

项目根目录放一个.editorconfig文件。

如果是 visual studio 项目,.editorconfig文件和 .sln 同级。

 

.editorconfig内容:

root = true

[*]
charset = utf-8-bom
indent_style = space
indent_size = 4
end_of_line = crlf
trim_trailing_whitespace = true
insert_final_newline = true

[*.cs]
charset = utf-8-bom

[*.cshtml]
charset = utf-8-bom

[*.config]
charset = utf-8-bom
indent_size = 2

 

.editorconfig 要放工程根目录,root = true 这行要加。

root = true 的意思是,当前.editorconfig这个文件就是总配置文件,不会在其它目录搜索.editorconfig。

 

posted on 2026-07-30 14:50  runliuv  阅读(2)  评论(0)    收藏  举报