C# Visual Studio 格式化整个文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1435691/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Visual Studio Format entire file?
提问by RCIX
Is there a way to issue a key command to properly format an entire file in VS2008 with CodeRush Express?
有没有办法在 VS2008 中使用 CodeRush Express 发出一个关键命令来正确格式化整个文件?
采纳答案by Vadim
Use Ctrl+K+Ctrl+Dto format document keystroke
使用Ctrl+ K+ Ctrl+D格式化文档击键
Use Ctrl+K+Ctrl+Fto format selection keystroke
使用Ctrl+ K+ Ctrl+F格式化选择击键
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.
也可以通过打开“选项...”对话框(从菜单中选择“工具”->“选项”)来设置您自己的击键。在选项对话框中选择环境->键盘形成树并为 Edit.FormatDocument 设置您自己的快捷方式。
回答by Igor Zevaka
I just use built-in Visual Studio formatting command: Ctrl+A, Alt+F8
我只是使用内置的 Visual Studio 格式化命令:Ctrl+ A, Alt+F8
回答by Tomas Aschan
回答by Dan McClain
You could always go to Tools -> Options -> Keyboardand give the Edit.FormatDocumenta new shortcut.
您可以随时转到工具 -> 选项 -> 键盘并为Edit.FormatDocument 提供一个新的快捷方式。
UpdateYou can also see what the Shortcuts mapped to this command are this way.
更新您还可以通过这种方式查看映射到此命令的快捷方式。
回答by Tony
Shortcut in visual studio to format the whole document is Ctrl+ E, D
在visual studio中格式化整个文档的快捷方式是Ctrl+ E,D
回答by John
Just select all content of page by Ctrl+ Athen click Ctrl+ Kand Ctrl+ D. The whole page tag format.
只需通过Ctrl+选择页面的所有内容,A然后单击Ctrl+K和Ctrl+ D。整个页面的标签格式。
For example see this link: Format the content
例如,请参阅此链接: 格式化内容
回答by Lucy
If Ctrl+E+Ctrl+DorCtrl+K+Ctrl+DorCtrl+K+Ctrl+Fdoesn'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.
如果 Ctrl+ E+ Ctrl+D或Ctrl+ K+ Ctrl+D或Ctrl+ K+ Ctrl+F不适合您,请尝试设置以下设置:Tools->Options -> Text Editor ->C# ->Tabs
,
确保选择了“保留标签”。
然后,返回到您的文本编辑器,重新尝试格式化。
I was really annoyed before, and steps above works for me. hope it works for you guys..
我以前真的很生气,上面的步骤对我有用。希望对你们有用..
回答by user3657964
Ctrl+E+Din Visual Studio Express 2013.
Ctrl+ E+D在Visual Studio Express的2013。