Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2013 Indentation Not Working While Writing

I have such a code:

class Myclass
{
}

I now want to add some code, e.g. 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. Also I checked Options -> Text Editor -> C# -> Formatting -> Indentation and "Indent block contents" is checked.

This is happening on Visual Studio 2013 with Resharper 8.1. I suspended Resharper temporarily and there is no difference. On the same machine I have Visual Studio 2012 with Resharper and it works normally.

Does anyone know what configuration has to be changed to have the indentation work during writing?

like image 682
Vladimir Avatar asked Apr 24 '14 11:04

Vladimir


People also ask

How do I turn on auto indent in Visual Studio?

Auto formatting settings in Visual Studio Show activity on this post. Select the text you want to automatically indent. Click menu Edit → Advanced → *Format Selection, or press Ctrl + K , Ctrl + F . Format Selection applies the smart indenting rules for the language in which you are programming to the selected text.

How do you indent paragraphs in Visual Studio code?

I want to indent a specific section of code in Visual Studio Code: Select the lines you want to indent, and. use Ctrl + ] to indent them.


2 Answers

I added this to .editorconfig (resharper config file)

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

like image 145
anil Avatar answered Oct 18 '22 01:10

anil


For VS 2019 remove ".editorconfig" file. Located in project/src/

like image 42
Mo D Genesis Avatar answered Oct 18 '22 01:10

Mo D Genesis