visual-studio Visual Studio 2005:有没有一种简单的方法可以在 ASPX 文件中正确缩进?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 
原文地址: http://stackoverflow.com/questions/630476/
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 2005 : Is there an easy way to indent correctly in an ASPX file?
提问by Cedric Aube
In Visual Studio 2005, is there a way to indent correctly the tags in the aspx file (not in .cs files but really in ASPX files which contain HTML/ASP code)?
在 Visual Studio 2005 中,有没有办法正确缩进 aspx 文件中的标签(不是在 .cs 文件中,而是在包含 HTML/ASP 代码的 ASPX 文件中)?
回答by Dan
You can fix indenting using the shortcut Ctrl-K+D
您可以使用快捷键 Ctrl-K+D 修复缩进
回答by James Curran
Those keystrokes translate to:
这些击键转换为:
- Ctrl-K, Ctrl-D: Edit/Advanced/Format Document
- Ctrl-A, Ctrl-K, Ctrl-F: Edit/Select All, Edit/Advanced/Format Selection
- Ctrl- K, Ctrl-D: 编辑/高级/格式化文档
- Ctrl- A, Ctrl- K, Ctrl-F: 编辑/全选,编辑/高级/格式选择
For some reason, the latter seems to work better for me.
出于某种原因,后者似乎更适合我。
Note, these also work for other file types: C#, VB, XML etc...
请注意,这些也适用于其他文件类型:C#、VB、XML 等...
回答by Sachin
Ctrl-A (select all), Ctrl-K-F has worked for me.
Ctrl-A(全选),Ctrl-KF 对我有用。
回答by Izmoto
XML Editor toolbar -> Format whole document.
XML 编辑器工具栏 -> 格式化整个文档。
回答by Izmoto
You want to go to Tools > Options and then navigate to Text Editor > All Languages > Tabs.
您要转到工具 > 选项,然后导航到文本编辑器 > 所有语言 > 选项卡。
The settings you want are: Under Indenting click the "Smart" Radio box for smart indenting. Under Tab you want tab size 4 and indent size 4. And check the radio button labeled Insert Spaces.
您需要的设置是: 在缩进下单击“智能”单选框以进行智能缩进。在 Tab 下,您需要 Tab 大小 4 和缩进大小 4。并选中标记为 Insert Spaces 的单选按钮。
You can also change these settings for each language individually. Also some of them don't have Smart indenting, like html.
您还可以单独更改每种语言的这些设置。还有一些没有智能缩进,比如 html。

