Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I set Visual Studio to use K&R style bracketing?

Tags:

c#

formatting

I really don't like this style of formatting:

Class AwesomeClass {     private static void AwesomeMethod()     {      }  } 

Can I make it format my code like this?

Class AwesomeClass {      private static void AwesomeMethod() {      } } 
like image 286
cory Avatar asked Jun 15 '10 20:06

cory


People also ask

How do I set Keybinds in Visual Studio?

On the menu bar, choose Tools > Options. Expand Environment, and then choose Keyboard. Optional: Filter the list of commands by entering all or part of the name of the command, without spaces, in the Show commands containing box. In the list, choose the command to which you want to assign a keyboard shortcut.

How do I change the code format in Visual Studio?

The code formatting is available in Visual Studio Code through the following shortcuts: On Windows Shift + Alt + F. On Mac Shift + Option + F. On Linux Ctrl + Shift + I.


2 Answers

Go to Tools > Options > Text Editor > C# > Formatting > New Lines.

In recent version of Visual Studio (at least 2017):

Tools > Options > Text Editor > C# > Code Style > Formatting > New Lines

Then just uncheck every option you see there.

like image 159
Matt Greer Avatar answered Oct 11 '22 06:10

Matt Greer


Tools > Options

Check "Show all settings"

Text Editor > C# > Formatting > New Lines

Uncheck the settings for where you want no extra newline added. Personally I always uncheck all items in this category.

like image 41
Guffa Avatar answered Oct 11 '22 06:10

Guffa