Visual Studio - “{ }”设置

发布于 2024-09-01 12:24:04 字数 344 浏览 1 评论 0原文

说实话,我不知道该谷歌什么。事情是这样的,我喜欢这种类似 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

柒夜笙歌凉 2024-09-08 12:24:04

转到工具>选项>文本编辑器> [语言,即:C#]>代码风格>格式化>新行

您可以在此处设置大括号的新行选项。

请参阅下图以获取更多说明。

menu

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.

menu

梦途 2024-09-08 12:24:04

文本编辑器 > C# > > 格式设置 > 新线 > 大括号的新行选项

  • 取消选中将左大括号放在控制块的新行上
  • 可能还想取消选中将其他内容放在换行符上

Text Editor > C# > Formatting > New Lines > New line options for braces

  • Uncheck Place open brace on new line for control blocks.
  • Probably want to uncheck put else on newline as well.
我不吻晚风 2024-09-08 12:24:04

这是针对 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 open Options. Make sure that the Show all settings checkbox is checked. Open the Text Editor node and then the node for the language you want to change the setting for. Open the Formatting node and select the New 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.

锦欢 2024-09-08 12:24:04

值得知道的是,史蒂夫·霍恩(和其他人)的答案甚至适用于其他语言,因为它们似乎没有相同的设置布局。我按照他的帖子中所述进行了更改,它也适用于我的 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文