Gor*_*rey 15 c# curly-braces visual-studio-code
使用“格式文档”命令时,我想更改代码格式。我是VSCode的新手,仍然无法浏览设置,因此易于理解的回复将非常有帮助。当前代码的格式如下:
void start ()
{
//Do stuff here
}
Run Code Online (Sandbox Code Playgroud)
我希望它看起来像:
void start () {
//Do stuff here
}
Run Code Online (Sandbox Code Playgroud)
Pin*_*yni 15
我已经找到了VScode的简单解决方案!
只需在项目的根目录下创建一个名为omnisharp.json的文件,然后粘贴以下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
}
}
Run Code Online (Sandbox Code Playgroud)
我在这里找到了解决方案:https : //medium.com/@wearetherock/visual-studio-code-c-put-the-opening-brace-on-the-same-line-as-the-statement-a98c552a544b
这对我有用:
.editorconfig
文件,内容如下:# CSharp formatting rules:
[*.cs]
csharp_new_line_before_open_brace = none
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3696 次 |
最近记录: |