[Phalanx] Visual Studio 2008的一些源码格式化配置

本文详细介绍了如何在Visual Studio 2008中为C#代码进行格式化的设置步骤,包括行号显示、缩进、换行及间距等方面的配置,并提供了快速格式化代码的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Visual Studio 2008里,在菜单的Tools->Options...->C#,
General里,把Line numbers打上钩;

Formatting里,

Indentation:
Indent block contents
Indent case contents
这两个打勾,其它不打勾;
Label Indentation选第二个:Place goto labels one indent less than current;

New Lines:
New line options for braces:
Place open brace on new line for types
New line options for expressions:
Place members in object initializers on new line
Place members in anonymous types on new line
Place query expression clauses on new line
以上打勾,其它不打勾;

Spacing:
Set spaceing for method declarations:
Insert space within argument list parentheses
Insert space within empty argument list parentheses
Set spacing for method calls:
Insert space within argument list parentheses
Insert space within empty argument list parentheses
Set other spacing options:
Insert space after keywords in control flow statements
Insert space within parentheses of expressions
Insert space within parentheses of type casts
Insert spaces inside parentheses for control flow statements
Insert space after cast
Set spacing for brackets:
Insert space within empty square brackets
Insert spaces within square brackets
Set spacing for delimiters:
Insert space after colon for base or interface in type declaration
Insert space after comma
Insert space after semicolon in "for" statement
Insert space before colon for base or interface in type declaration
以上打勾,其它不打勾;
Set spacing for operators,选第一个:Insert space before and after binary operators。

在完成以上配置后,按Ok来保存设置。
以后,在C#的代码编辑界面里,按Ctrl+E,D(按着Ctrl的同时依次按下E和D)或者在菜单的Edit->Advanced->Format Document就可以对C#源代码做自动的格式化。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值