In Eclipse there is a shortcut, Ctrl+Shift+F, that re-indents code and fixes comments and blank lines. Is there an equivalent for Visual Studio 2010?
This question is related to
c#
visual-studio-2010
visual-studio
visual-studio-2012
visual-studio-2013
To align the text in the proper format -
Ctrl + K + D for front end pages like .aspx
or .cshtml
Ctrl + K + F for a .cs
page
But observe to press all buttons in sequence...
Format the entire document:
Ctrl + K + D
ReSharper - Ctrl + Alt + F
Visual Studio 2010 - Ctrl + K, Ctrl + D
Select all text in the document and press Ctrl + E + D.
Yes, you can use the two-chord hotkey (Ctrl+K, Ctrl+F if you're using the General profile) to format your selection.
Other formatting options are under menu Edit → Advanced, and like all Visual Studio commands, you can set your own hotkey via menu Tools → Options → Environment → Keyboard (the format selection command is called Edit.FormatSelection
).
Formatting doesn't do anything with blank lines, but it will indent your code according to some rules that are usually slightly off from what you probably want.
Change these shortcuts in Visual Studio
Tools ? Options ? Environment ? Keyboard
and then change the command
"Edit.FormatDocument" or "Edit.FormatSelection"
assign the same shortcut alt + shift +f
as in visual studio code in order to not remember another one and confuse between each other.
Ctrl + K + D (Entire document)
Ctrl + K + F (Selection only)
Try Ctrl + K + D (don't lift the Ctrl key in between).
Simply
For Visual Studio Code
Use ALt + Shift + F
for Visual Studio IDE
Press Ctrl + K followed by Ctrl + D
It will beautifully format the entier file.
Source: Stackoverflow.com