C
C#6mo ago
yourFriend

How to open brace on new line by default for C# or any language in vs code?

I want this by default:
if(condition)
{
code here;
}
if(condition)
{
code here;
}
Instead of:
if(condition){
code here;
}
if(condition){
code here;
}
5 Replies
yourFriend
yourFriendOP6mo ago
Yes
Angius
Angius6mo ago
Try an .editorconfig file https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/csharp-formatting-options#new-line-options
[*.cs]
csharp_new_line_before_open_brace = all
[*.cs]
csharp_new_line_before_open_brace = all
ero
ero6mo ago
I don't think VSCode has such a feature. You need to get used to Enter Brace Enter
yourFriend
yourFriendOP6mo ago
Yeah, I'll just do this for now. I do see some extensions for .editorconfig in VS Code. Might try them some day.
ero
ero6mo ago
i don't believe an editorconfig will place braces on a new line while typing. i could see it doing so when formatting the file (ideally with formatOnSave turned on)

Did you find this page helpful?