Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Code Formatting in Visual Studio

Tags:

Is there some combination of keys or a menu option that I can use to automatically format my code in Visual Studio?

like image 867
Sachin Kainth Avatar asked Feb 08 '12 16:02

Sachin Kainth


People also ask

How do I get beautify code in Visual Studio?

In an existing project, open the document that you want to format, right-click inside the document, and select Format Document. In the default configuration for Visual Studio Code, the command can be run using the shortcut Alt+Shift+F.

How do I automatically format code in Visual Studio Code?

To automatically format the file on save, In Visual Studio Code, press Control + Shift + P or Command + Shift + P (Mac) to open the command palette and type setting and then select Preferences: Open User Settings option. Search for format on save setting and check the checkbox.


1 Answers

It sounds like you want to format the entire document in Visual Studio (this feature is some times referred to as pretty printing). If so then you can use the menu command. Edit -> Advanced -> Format Document. This is typically bound to the key stroke CTRL+KCTRL+D

like image 159
JaredPar Avatar answered Oct 05 '22 07:10

JaredPar