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。

浙公网安备 33010602011771号