Visual Studio缩进设置为两个空格,而不是四个空格选项卡

DaI*_*mTo 4 c# visual-studio .net-core

我刚刚在这里打开一个旧项目。似乎有人更改了缩进。它设置为2个空格,而不是四个空格制表符。

在此处输入图片说明

我尝试过的

  1. 我试着做一个Cntrl K + D,但这并没有将其更改回适当的缩进。
  2. 我删除了_ReSharper.Caches目录,并创建了一个新目录,但缩进没有变化。

当这些方法不起作用时,我已开始将Visual Studio中的设置与两种不同的解决方案进行比较。

Resharper设置的矛头是相同的广告,是Visual Studio中的设置。

重新分享设定

在此处输入图片说明

Visual Studio设置

在此处输入图片说明

哪个使我认为这必须在项目文件之一中?如果不是我的Visual Studio中的设置有问题,什么是覆盖制表符?

值得注意的是,当我加载项目时,我发誓它会加载适当的缩进,然后在最后一秒重新格式化。不确定是否重要,但是项目是.net core 1.0,解决方案中有三个项目,所有三个项目似乎都受到了影响。

希望有人对此有修正,真的很难像这样阅读。

Ogg*_*las 7

As people says in answers and comments this is probably a .editorconfig. In our case a developer started using VS Code and when upgrading to VS 2017 Visual Studio also accepts these files.

This was the value in the file that was automatically added:

[*]
end_of_line = crlf
insert_final_newline = true
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
Run Code Online (Sandbox Code Playgroud)

By adding this we could use C# normally and the developer who wanted to use VS Code could continue to do that:

[*.cs]
indent_style = space 
indent_size = 4
Run Code Online (Sandbox Code Playgroud)

https://developercommunity.visualstudio.com/content/problem/44231/cant-set-indent-level-to-4-spaces-in-vs-2017.html


yaa*_*kov 6

Visual Studio可能在项目目录(或任何父目录)中使用.editorconfig文件,无论用户设置如何,该文件都可以在代码库中提供一致的代码样式。

Visual Studio应在IDE窗口的左下方区域中进行指示。

在这种情况下,您将需要修改.editorconfig和定义新样式,以更改自动格式化工具的配置。