惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
The Blog of Author Tim Ferriss
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
云风的 BLOG
云风的 BLOG
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
P
Palo Alto Networks Blog
D
Docker
H
Hackread – Cybersecurity News, Data Breaches, AI and More
S
Schneier on Security
Engineering at Meta
Engineering at Meta
I
InfoQ
L
LangChain Blog
Cyberwarzone
Cyberwarzone
T
Tenable Blog
WordPress大学
WordPress大学
P
Privacy & Cybersecurity Law Blog
罗磊的独立博客
Apple Machine Learning Research
Apple Machine Learning Research
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Jina AI
Jina AI
C
CERT Recently Published Vulnerability Notes
Scott Helme
Scott Helme
博客园 - 三生石上(FineUI控件)
酷 壳 – CoolShell
酷 壳 – CoolShell
Know Your Adversary
Know Your Adversary
D
Darknet – Hacking Tools, Hacker News & Cyber Security
The Last Watchdog
The Last Watchdog
Last Week in AI
Last Week in AI
Cloudbric
Cloudbric
S
SegmentFault 最新的问题
爱范儿
爱范儿
Application and Cybersecurity Blog
Application and Cybersecurity Blog
博客园 - 叶小钗
AI
AI
T
Tor Project blog
I
Intezer
T
Threatpost
www.infosecurity-magazine.com
www.infosecurity-magazine.com
V
Visual Studio Blog
N
News and Events Feed by Topic
Latest news
Latest news
S
Security Affairs
博客园 - Franky
Microsoft Security Blog
Microsoft Security Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
B
Blog RSS Feed
C
Cybersecurity and Infrastructure Security Agency CISA
Hugging Face - Blog
Hugging Face - Blog
小众软件
小众软件
S
Securelist

博客园 - barney

更好的执行 浅谈代码生成工具《CodeSmith》的使用(1) 数据库设计经验 ie8 自动设置 兼容性 代码 求助 一个彩票的算法问题 ! 使用VS2005调试ASP程序 基于.NET平台的Windows编程实战 如何创建一个标准的Windows服务 zhuan最近的一些想法与大家分享 机会来了,你做好准备了吗? XPath详解,总结 ASP.NET分页存储过程自定义用户控件 常用js 大全 [转载]《穷爸爸,富爸爸》读后感 四款PDF文档制作软件 VS2005(c#)项目调试问题解决方案集锦 VS2005中调试javascript 未能向文件“.csproj.FileListAbsolute.txt”写入命令行 对路径 的访问被拒绝。2008年05月27日 星期二 下午 05:16 sql使用convert转化
VS2005中的代码格式化
barney · 2009-03-10 · via 博客园 - barney

      记得以前使用JBuider2006搞Java开发的时候有一个“FormatAll”的功能非常棒,就是将当前文档的代码按格式缩进,显得非常整洁,方便阅读和修改。到了VS2005之后一直都在用下面的笨办法实现代码格式化(缩进),今天偶然发现VS2005中也有类似于“FormatAll”的功能。。。。。
      实现代码格式化的方法有以下两种:
     方法一:对文档最后一个大括号进行删除再添加的动作以便VS2005自动格式化。
    例如:有以下的这么一段代码

 1namespace phcis
 2 {
 3
 4    static class Program
 5    {
 6        
 7         /// <summary>
 8        /// 应用程序的主入口点。
 9        /// </summary>

10        [STAThread]
11
12        static void Main()
13        {
14
15            Application.EnableVisualStyles();
16            Application.SetCompatibleTextRenderingDefault(false);
17            Application.Run(new frmMain());
18
19        }

20
21     }

22
23  }

24

   我们需要将整个文档都进行格式化的时候可以将23行的大括号(})先删除然后再输入一个大括号(}),看看代码是不是自动格式化了?
   当然,如果只是需要对某个方法如static void Main()进行格式化,那就将19行的大括号(})先删除再添加。。。

  方法二:直接使用VS2005的快捷键进行格式化
   想对某个文档进行快速格式化可直接按组合键Ctrl+K,然后会看到状态栏的最左端会显示“(Ctrl+K)已被按下,正在等待第二个按键。”,此时再按下“D”键即可完成整个代码的格式化工作咯。
   如果仅仅想对某一段代码进行格式化,可以选中这段代码,然后单击鼠标右键,在弹出菜单中选择“设置选定内容格式”,不过并非任何代码段都会出现此选项。

    上面的功能对应菜单项是:“编辑”--“高级”--“设置文档格式”/“设置选定内容格式”,请灵活应用。