VSCode格式大括号放在同一行C# [英] VSCode format curly brackets on the same line c#

查看:1155
本文介绍了VSCode格式大括号放在同一行C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用格式文档"命令时,我想更改代码格式. 我是VSCode的新手,但仍无法浏览设置,因此易于理解的回复将非常有帮助. 目前,代码的格式如下:

When using the Format Document command I'd like to change how the code formats. I'm completely new to VSCode and I'm still having trouble navigating the settings, so easy to understand replies would be very helpful. Currently the code is formatting like this:

void start ()
{
//Do stuff here
}

我希望它看起来像:

void start () {
//Do stuff here
}

推荐答案

我已经找到了VScode的简单解决方案!

I have found this simple solution for VScode !

只需在项目的根目录下创建一个名为 omnisharp.json 的文件,然后粘贴以下JSON即可:

Just create a file called omnisharp.json at the root of your project and paste the following JSON :

{
    "FormattingOptions": {
        "NewLinesForBracesInLambdaExpressionBody": false,
        "NewLinesForBracesInAnonymousMethods": false,
        "NewLinesForBracesInAnonymousTypes": false,
        "NewLinesForBracesInControlBlocks": false,
        "NewLinesForBracesInTypes": false,
        "NewLinesForBracesInMethods": false,
        "NewLinesForBracesInProperties": false,
        "NewLinesForBracesInObjectCollectionArrayInitializers": false,
        "NewLinesForBracesInAccessors": false,
        "NewLineForElse": false,
        "NewLineForCatch": false,
        "NewLineForFinally": false
    }
}

我在这里找到了解决方案: https://medium.com/@wearetherock/visual-studio-code-c-put-the-opening-brace-on-the-same-line-as-the-statement-a98c552a544b

I found the solution here: https://medium.com/@wearetherock/visual-studio-code-c-put-the-opening-brace-on-the-same-line-as-the-statement-a98c552a544b

这篇关于VSCode格式大括号放在同一行C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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