问题描述
使用格式文档"命令时,我想更改代码格式.我是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
}
}
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#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!