When I auto-format my code in VS Code it formats to:
void funtion()
{
}
How can I change it to auto-format to this:
void foo() {
}
Thanks!
When I auto-format my code in VS Code it formats to:
void funtion()
{
}
How can I change it to auto-format to this:
void foo() {
}
Thanks!
EDIT: VISUAL STUDIO CODE
I'd like to change my answer. I realized you were actually talking about Visual Studio Code later, even though you correctly specified that with your tags. My apologies.
In all fairness things are different. As per this link, you should
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 globally
In my case, no such file existed. So I went to C:\Users\MyUserName.omnisharp (on Windows; bear with me, I'll also write that for Mac) and created a text file, filled it with the above content and renamed it omnisharp.json
Then, pressing Shift + Alt + F to auto-format code (which works for Mac too), I got
void foo() {
}
In your case, as per this link, the omnisharp folder on Mac should be at
~/.vscode/extensions/ms-vscode.csharp-1.x.x/bin/omnisharp
Where 1.x.x is the version of Omnisharp/C# extension for VS Code that you have installed.
All previous steps (to get started with C# development) were here.
I assume you are talking about C# from your syntax. From the Tools menu choose Options, open the TreeView to the left like in the image below and then uncheck any option regarding new lines and braces, i.e. "Place open brace on new line for types" and all the others you want to change:
In your case, since you are talking about methods, you should uncheck "Place open brace on new line for methods and local functions", the second option from the top.
Since you ask about iOS, here's the Tool menu:
UPDATE!
OmniSharp now has a global configuration:
macOS/Linux: ~/.omnisharp/omnisharp.json
Windows: %APPDATA%\OmniSharp\omnisharp.json