I've been searching for this for hours and just can't find it. Is there any way to stop the "formatting" for C# from kicking my open curly braces down onto their own line?
Me too... very annoying
This is really the only major thing preventing me from switching to Visual Studio Code. It's really frustrating. I love everything else about the OmniSharp extension. It's the greatest thing since grilling.
Hello folks, try to use C# FixFormat
It have this option: csharpfixformat.style.braces.onSameLine:
Thanks @bernardbr, I'll give that a look. But I'd still really like this to be baked into OmniSharp by default. I don't really understand how it isn't already. I have to assume there's a technical reason for the decision.
@ciel it's a default convention of Microsoft's Guideline Code Style.
Maybe the OmniSharp's team at the first time have set it as default behavior and someday they put this option on rails.
This is already supported by OmniSharp.
Add the following setting:
{
"FormattingOptions": {
"NewLinesForBracesInLambdaExpressionBody": false,
"NewLinesForBracesInAnonymousMethods": false,
"NewLinesForBracesInAnonymousTypes": false,
"NewLinesForBracesInControlBlocks": false,
"NewLinesForBracesInTypes": false,
"NewLinesForBracesInMethods": false,
"NewLinesForBracesInProperties": false,
"NewLinesForBracesInAccessors": false,
"NewLineForElse": false,
"NewLineForCatch": false,
"NewLineForFinally": false
}
}
to:
omnisharp.json at the root of your project (the folder which you open in VS Code) - if you want to enforce this change on a specific project only %USERDATA%/.omnisharp/omnisharp.json if you want to enforce this globallyThank you SO much for this! Is there a specific reason these options aren't part of the omnisharp configuration options in the /.vscode/settings.json file?
/.vscode/settings.json is a VS Code specific file - while the omnisharp.json options are editor-independent.
For example you could open the same project using VS Code, Emacs or Vim and if you have OmniSharp installed in each of them, the same formatting rules will be used.
BTW - here is a full list of available formatting options - https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/omnisharp.json along with their default values.
Okay. That's a fair answer. I can respect that. Thank you so, so much. This will make Visual Studio Code a billion times better!
What is the possibility that the Visual Studio Code extension could include a hard-coded "setting" that is like ...
// use advanced omnisharp settings declared in omnisharp.json.
// see https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/omnisharp.json for details
"omnisharp.useOmniSharpJsonSettings : true"
That'll show in the Visual Studio Code settings pane, just as a way to direct users to it? I feel it would ease confusion if users at least had something in Visual Studio Code that said _"Hey! You can configure this!!"_
thanks - this is probably a bit excessive, but point is well taken - we should work on making it more visible/discoverable.
I wrote a blog post a while ago https://www.strathweb.com/2017/01/c-code-formatting-settings-in-vs-code-and-omnisharp/ however it would need to be updated to the latest developments as it was written against an older version of OmniSharp. Same with the wiki on the server repo https://github.com/OmniSharp/omnisharp-roslyn/wiki/Configuration-Options
FYI: If there is no omnisharp.json in the project root, then create one.
/.vscode/settings.jsonis a VS Code specific file - while theomnisharp.jsonoptions are editor-independent.
For example you could open the same project using VS Code, Emacs or Vim and if you have OmniSharp installed in each of them, the same formatting rules will be used.
It still would be nice to have these options in VSCODE.
There is a global and workspace setting that was mentioned. Having one for User Settings (vscode) it'd be nice.
Hola, como me funciono:
Most helpful comment
This is already supported by OmniSharp.
Add the following setting:
to:
omnisharp.jsonat the root of your project (the folder which you open in VS Code) - if you want to enforce this change on a specific project only%USERDATA%/.omnisharp/omnisharp.jsonif you want to enforce this globally