Visual Studio 2005/2012:如何使第一个大括号保持在同一行上? [英] Visual Studio 2005/2012: How to keep first curly brace on same line?

查看:371
本文介绍了Visual Studio 2005/2012:如何使第一个大括号保持在同一行上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

试图让我的css/C#函数看起来像这样:

Trying to get my css / C# functions to look like this:

body {
    color:#222;
}

代替此:

body 
{
    color:#222;
}

当我自动设置代码格式时.

when I auto-format the code.

推荐答案

C#

  1. 工具菜单中,单击选项
  2. 单击显示所有参数(左下方的复选框)(在VS 2010中显示显示所有设置)
  3. 文本编辑器
  4. C#
  5. 格式化
  6. 换行
  1. In the Tools Menu click Options
  2. Click Show all Parameters (checkbox at the bottom left) (Show all settings in VS 2010)
  3. Text Editor
  4. C#
  5. Formatting
  6. New lines

在那里检查是否需要带括号的新行

And there check when you want new lines with brackets

CSS:

几乎相同,但选项更少

  1. 工具菜单中,单击选项
  2. 单击显示所有参数(左下方的复选框)(在VS 2010中显示显示所有设置)
  3. 文本编辑器
  4. CSS
  5. 格式化
  1. In the Tools Menu click Options
  2. Click Show all Parameters (checkbox at the bottom left) (Show all settings in VS 2010)
  3. Text Editor
  4. CSS
  5. Format

然后选择所需的格式(在您的情况下,选择第二个单选按钮)

And than you select the formatting you want (in your case second radio button)

对于Visual Studio 2015:

工具→选项

在边栏中,转到文本编辑器→C#→格式→新行

In the sidebar, go to Text Editor → C# → Formatting → New Lines

并取消选中括号的换行选项"

这篇关于Visual Studio 2005/2012:如何使第一个大括号保持在同一行上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆