如何让Rider对.csproj文件自动格式化时使用2空格缩进而非4空格?
解决Rider格式化.csproj文件缩进不生效的问题
先检查Rider对EditorConfig的开关
进入Editor > Code Style > General,确认勾上了Use EditorConfig settings,且该选项优先级高于内部设置。补加MSBuild专属缩进规则
.csproj属于MSBuild格式,原有EditorConfig规则覆盖不全,直接在配置里补充专属规则:[*.csproj] indent_style = space indent_size = 2 msbuild_indent_style = space msbuild_indent_size = 2清除Rider配置缓存
打开File > Invalidate Caches...,选择"Invalidate and Restart",清空旧配置缓存后重启软件。确认格式化范围与选项
按下Ctrl+Alt+L时,要么选中整个.csproj文件,要么去Editor > Code Style > Formatting里确认,格式化选项包含缩进相关设置。
内容的提问来源于stack exchange,提问作者Aleksej_Shherbak
相关产品推荐
相关产品推荐

