Visual Studio - “{ }”设置
说实话,我不知道该谷歌什么。事情是这样的,我喜欢这种类似 Java 的代码编写:
if (condition == true) {
doSomeStuff();
}
但是 VisualStudio 用它自己的“风格”“帮助”我,我不喜欢这种风格,而且我无法更改(在拼命检查所有设置之后花了相当长的时间:/ )
if (condition == true)
{
DoStuff();
}
我显然希望“{”字符位于条件为...的同一行中...
我正在使用 MS Visual Studio 2010 professional。
Seriously, I don't know what to google. Here's the thing, I like this Java-like code writing:
if (condition == true) {
doSomeStuff();
}
But VisualStudio "helps" me with its own "style", which I don't like and I am unable to change (after rather big time of desperate checking all settings :/)
if (condition == true)
{
DoStuff();
}
I obviously want the "{" char to be in same line where condition is ...
I am using MS Visual Studio 2010 professional.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
转到工具>选项>文本编辑器> [语言,即:C#]>代码风格>格式化>新行
您可以在此处设置大括号的新行选项。
请参阅下图以获取更多说明。
Go to Tools > Options > Text Editor > [Language, i.e.: C#] > Code Style > Formatting > New Lines
This is where you can set your new line options for braces.
See the image below for more clarification.
工具->选项...
替代文本http://img6.imageshack.us/img6/158/capturejo.png
Tools -> Options ...
alt text http://img6.imageshack.us/img6/158/capturejo.png
文本编辑器 > C# > > 格式设置 > 新线 > 大括号的新行选项
将左大括号放在控制块的新行上
。将其他内容放在换行符上
。Text Editor > C# > Formatting > New Lines > New line options for braces
Place open brace on new line for control blocks
.put else on newline
as well.这是针对 Visual Stuio 2008 的,所以我不确定它在 VS 2010 中是否完全相同:
转到
Tools
菜单并打开Options
。确保选中显示所有设置
复选框。打开文本编辑器
节点,然后打开您要更改设置的语言的节点。打开Formatting
节点并选择New Lines
节点。当新行添加到代码中时,您可以在此处进行更改。安装 Visual Studio 后,我进入那里并取消选中
New Lines
部分中的每个选项。This is for Visual Stuio 2008, so I'm not sure that it's exactly the same in VS 2010:
Go to the
Tools
menu and openOptions
. Make sure that theShow all settings
checkbox is checked. Open theText Editor
node and then the node for the language you want to change the setting for. Open theFormatting
node and select theNew Lines
node. Here you can change when new lines are added to the code.After installing Visual Studio I go in there and uncheck every option in the
New Lines
section.值得知道的是,史蒂夫·霍恩(和其他人)的答案甚至适用于其他语言,因为它们似乎没有相同的设置布局。我按照他的帖子中所述进行了更改,它也适用于我的 C++ 项目。
Worth knowing is that Steve Horn's (and others) answer works even for other languages as they seem to appear to not have the same settings-layout. I did the changes as described in his post and it worked for my C++ projects as well.