Visual Studio Format entire file?
Asked Answered
S

8

47

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

Sylvester answered 16/9, 2009 at 21:51 Comment(2)
When you select Edit->Advanced from menu what keystrokes do you see for Format Document?Exertion
Or if you need to do it automatically, the .NET foundation released their code formatting tool on GitHub: github.com/dotnet/codeformatterUrsola
E
105

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.

Exertion answered 16/9, 2009 at 21:53 Comment(6)
That is, press "Ctrl+K", release it, and then press "Ctrl+D".Uphill
@Sylvester When you select Edit->Advanced from menu what keystrokes do you see for Format Document?Exertion
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 tooSylvester
This looks more like CodeRush problem to me.Uphill
It should be noted that Ctrl+K, D is a VS shortcut, and not a CodeRush commandChesnut
This doesn't work on Visual Studio 2019 for me. Tried both combinations, nothing happened.Palmer
G
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.

Grad answered 16/9, 2009 at 21:56 Comment(3)
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.Exertion
I was just giving you a hard time, no worriesGrad
There is no Options in the Tools menu on VS Community for Mac.Giraffe
R
7

Ctrl+K,Ctrl+D

This question with answers has a lot of handy tips.

Reportage answered 16/9, 2009 at 21:54 Comment(0)
J
2

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

Jigsaw answered 9/5, 2012 at 11:28 Comment(0)
K
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

Kazak answered 21/10, 2012 at 19:27 Comment(0)
M
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..

Maverick answered 26/10, 2012 at 10:59 Comment(0)
P
0

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

Pointer answered 16/9, 2009 at 21:53 Comment(0)
O
0

Ctrl+E+D in Visual Studio Express 2013.

Okwu answered 28/5, 2014 at 22:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.