简体   繁体   English

Visual Studio 2013缩进在写作时不起作用

[英]Visual Studio 2013 Indentation Not Working While Writing

I have such a code: 我有这样的代码:

class Myclass
{
}

I now want to add some code, eg a method. 我现在想添加一些代码,例如方法。 I go right after the } and press enter expecting to get this (| is the place of the cursor): 我在}之后然后按下输入期望得到这个(|是光标的位置):

class Myclass
{
    |
}

However I get this: 但是我得到了这个:

class Myclass
{
|
}

If I now enter a method it stays like this: 如果我现在输入一个方法,它就像这样:

class Myclass
{
public void A()
    { }
}

My configuration for indentation is correct because once I press Ctrl+K, D it gets fixed. 我的缩进配置是正确的,因为一旦按下Ctrl + K,D就会得到修复。 Also I checked Options -> Text Editor -> C# -> Formatting -> Indentation and "Indent block contents" is checked. 我还选中了选项 - >文本编辑器 - > C# - >格式化 - >缩进,并选中了“缩进块内容”。

This is happening on Visual Studio 2013 with Resharper 8.1. 这是在带有Resharper 8.1的Visual Studio 2013上发生的。 I suspended Resharper temporarily and there is no difference. 我暂时暂停了Resharper,没有任何区别。 On the same machine I have Visual Studio 2012 with Resharper and it works normally. 在同一台机器上,我使用带有Resharper的Visual Studio 2012,它可以正常工作。

Does anyone know what configuration has to be changed to have the indentation work during writing? 有没有人知道在写作过程中必须更改哪些配置才能使缩进工作?

I found the setting that is messing this up: it is Options->Text Editor->All Languages->Tabs->Indenting. 我发现这个设置搞砸了:它是选项 - >文本编辑器 - >所有语言 - >选项卡 - >缩进。 I had it set to Block and it should be Smart 我把它设置为Block,它应该是Smart

I added this to .editorconfig (resharper config file) 我把它添加到.editorconfig(resharper配置文件)

brace_style = next_line

if anyone wants to go through the configurations in editorconfig file https://www.jetbrains.com/help/resharper/2017.1/EditorConfig_CSHARP_BracesPageSchema.html 如果有人想要在editorconfig文件中进行配置https://www.jetbrains.com/help/resharper/2017.1/EditorConfig_CSHARP_BracesPageSchema.html

For VS 2019 remove ".editorconfig" file. 对于VS 2019,删除“.editorconfig”文件。 Located in project/src/ 位于project / src /

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM