46

Is there a way to issue a key command to properly format an entire file in VS2008 with CodeRush Express?

RCIX
  • 38,647
  • 50
  • 150
  • 207
  • 2
    When you select Edit->Advanced from menu what keystrokes do you see for Format Document? – Vadim Sep 16 '09 at 22:31
  • Or if you need to do it automatically, the .NET foundation released their code formatting tool on GitHub: https://github.com/dotnet/codeformatter – Babak Apr 04 '17 at 05:19

8 Answers8

103

Use Ctrl+K+Ctrl+D to format document keystroke

Use Ctrl+K+Ctrl+F to format selection keystroke

It's also possible to set your own keystrokes by opening Options... dialog (select Tools->Options from the menu). In Options dialog select Environment->Keyboard form the tree and set your own shortcuts for Edit.FormatDocument.

Vadim
  • 21,044
  • 18
  • 65
  • 101
9

You could always go to Tools -> Options -> Keyboard and give the Edit.FormatDocument a new shortcut.

Update You can also see what the Shortcuts mapped to this command are this way.

Dan McClain
  • 11,780
  • 9
  • 47
  • 67
7

Ctrl+K,Ctrl+D

This question with answers has a lot of handy tips.

Community
  • 1
  • 1
Tomas Aschan
  • 58,548
  • 56
  • 243
  • 402
2

Shortcut in visual studio to format the whole document is Ctrl + E, D

icodebuster
  • 8,890
  • 7
  • 62
  • 65
Tony
  • 21
  • 1
2

Just select all content of page by Ctrl + A then click Ctrl + K and Ctrl + D. The whole page tag format.

For example see this link: Format the content

icodebuster
  • 8,890
  • 7
  • 62
  • 65
John
  • 21
  • 1
2

If Ctrl+E+Ctrl+D or Ctrl+K+Ctrl+D or Ctrl+K+Ctrl+F doesn't work for you, try to set below settings:
Tools->Options -> Text Editor ->C# ->Tabs,
make sure `Keep tabs is selected.
Then, go back to your text editor, re-try formatting.

I was really annoyed before, and steps above works for me. hope it works for you guys..

Hulk1991
  • 3,079
  • 13
  • 31
  • 46
Lucy
  • 21
  • 1
0

I just use built-in Visual Studio formatting command: Ctrl+A, Alt+F8

icodebuster
  • 8,890
  • 7
  • 62
  • 65
Igor Zevaka
  • 74,528
  • 26
  • 112
  • 128
0

Ctrl+E+D in Visual Studio Express 2013.

ItamarG3
  • 4,092
  • 6
  • 31
  • 44
user3657964
  • 41
  • 1
  • 6