Is there a way to issue a key command to properly format an entire file in VS2008 with CodeRush Express?
-
2When 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 Answers
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.

- 21,044
- 18
- 65
- 101
-
1
-
@RCIX When you select Edit->Advanced from menu what keystrokes do you see for Format Document? – Vadim Sep 16 '09 at 22:04
-
And on top of that when i use snippets (like pressing tab twice after typing if) i get all screwed up indenting, and osme CR refactorings get that too – RCIX Sep 16 '09 at 22:28
-
-
It should be noted that Ctrl+K, D is a VS shortcut, and not a CodeRush command – seFausto Mar 03 '10 at 05:41
-
This doesn't work on Visual Studio 2019 for me. Tried both combinations, nothing happened. – Aaron Franke Aug 05 '21 at 21:24
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.

- 11,780
- 9
- 47
- 67
-
It looks like mentioned about Edit.FormatDocment before last edit of my question. I honestly didn't see your answer. But you definitely deserve +1 but being first. – Vadim Sep 16 '09 at 22:30
-
-
Ctrl+K,Ctrl+D
This question with answers has a lot of handy tips.

- 1
- 1

- 58,548
- 56
- 243
- 402
Shortcut in visual studio to format the whole document is Ctrl + E, D

- 8,890
- 7
- 62
- 65

- 21
- 1
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

- 8,890
- 7
- 62
- 65

- 21
- 1
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..
I just use built-in Visual Studio formatting command: Ctrl+A, Alt+F8

- 8,890
- 7
- 62
- 65

- 74,528
- 26
- 112
- 128