Search code examples
c#visual-studioformattingvisual-studio-2017curly-braces

C# Curly Brace Formatting Visual Studio 2017


I'm new to Visual Studio Code and I have moved there from Atom since I'm learning C#. This is also my first time posting a question here, so pardon me if I haven't done a good job.

for(int i = 1; i < args.Length; i++){<cursor>}

I want to be able to press enter and the code should look like:

for(int i = 1; i < args.Length; i++)
{
    <cursor>
}

I know other people have faced similar problems but I've researched for hours and fiddled around with the setting to no success. I am using Visual Studio 2017, latest version.

Please ask questions if you need any more information. Thanks!


Solution

  • Thank you for all the feedback guys, I managed to fix it.

    In Tools > Options > Text Editor > C# > Tabs:

    I had switched to Block (from Smart) because Smart Tabs made the ending curly brace go all the way to the left. I tried switching it back and forth, but it didn't solve the problem.

    I was reading up on another issue where the person who asked the question added a comment saying that new files didn't have the issue. So, I tried this with the original settings on a new file and it worked without a problem :)

    Sorry for the trouble, thanks once again for all the tips!