-
Notifications
You must be signed in to change notification settings - Fork 29.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closing Brace auto-indent doesn't work properly #40235
Comments
Any updates on the issue ? |
Is there any action or update on this item? |
Can this be prioritized? Its preventing omnisharp from implementing standard C# bracket formatting. See dotnet/vscode-csharp#1906 and dotnet/vscode-csharp#1591). This makes using VS Code for C# a non-starter in my org. |
Yes, this is particularly frustrating that being a flagship language made my Microsoft and a flagship editor made by the same company, they cannot make such a simple thing work out of box, for years. |
Keep in mind this is not the same as Visual Studio (they're probably not the same team as well), so this kind of feature may take a while as it may break existing functionality @pengshao82 |
Do we have any updates regarding this? The issue that this has linked has been open since 2017. |
@sr229 I know, that is why I was referring vscode as flagship "editor" instead of IDE. VS on the other hand handles this just fine as I use it in my daily work. But for performance reason we are thinking of encouraging people to switch to VS code and this bug was pretty much a joy killer that took us by big surprise... |
the problem i'm facing now |
Closing this since after 3 years it has one upvote (plus a handful of comments that are essentially upvotes) While this is a bug, it does not break the code and is fixed by running format (protip: try enabling format on save!) |
I think saying this has one upvote is short sighted. There are multiple issues linked to this and someone complained 9 days before you made your message. I am still having this problem as well |
there are several other editors that have preferences panels for this, it's about time vscode was less prescriptive considering how many developer communities it supports. The original team dismissed this and said there was only two ways to do code bracing and indenting 'ever', and I've argued this config panel since day 1 of vscode. It would solve a lot of developer issues just to give control to the DEVELOPER on how they format code so that plugins for languages could also default to what THEY use, not what core team think in theory what you should use. The limited support for bracing, indentation and brackets has made this editor frustrating (and laughable) for years. Why not just look at other editors and see what they have done, then do similar... tried and TESTED solutions. #sigh instead of this elitist 'we know better' about how you should code 'theory'. Pretty much EVERY other editor has implmented this, why? because it makes sense. #intentingispersonal https://mondrian.pentaho.com/images/code_indentation.png |
I truly hope y'all reconsider this issue. Yes it might not break anything but the simple things that make life easier are what make people stay. |
Still having this issue. Most annoying thing in VS Code for me. |
Would also like to voice my frustration on this. It prevents me from using VSCode with C# for years now. And I don't think there are only a handful of users who are frustated by this, is just that the git issues are hard to find on google (i.e searching for "vscode C# place brace on new line" on Google does not point to any of the relevant issues) |
For anyone seeing this in the future. I've found a workaround to automatically place braces on a new line by using
This is not a perfect solution, as it jumps the line when you type |
I got @gabrieldechichi's solution to work when Add to settings.json:
Add to keybindings.json:
This keybind is active while editing C# documents only. This solves pretty much all of my formatting issues. |
It's something that should be as simple as a line in settings.json. I don't understand why they keep ignoring it. |
It seemed to work fine after disabling some extensions, but it's back @gabrieldechichi. I was trying this (really cheap) trick using comments as placeholders:
Anyway formatDocument seems to work asynchronously, so some some sort of onCompletion event is needed to time the placeholder removal. If anyone is willing to mess around a bit I leave a shortcut to the full list of commands. I miss Visual Studio a bit more for every minute I spend on this. |
A workaround is to add this to settings.json while having the macros extension added |
Since somehow none of the above worked for me, I went ahead and made a (probably) needlessly long macro to do what I wanted. For this as above you will need the macro extension. Put this in settings.json:
Put this is keybindings.json:
You will have to use Shift+Enter when wanting to do this. Make a curly, once inside the automatic 2 hold shift and press enter. |
Ironcutter that worked for me! I spent wayyyy too long trying to solve this. But i'll be damned if i have confusing bracket placement. |
I wrote a really minimal vscode extension (C# Curly Formatter) to solve curly brackets indentation problems. |
You ABSOLUTE Legend |
Steps to Reproduce:
Expected
The closing brace is indented properly
Actual Behavior
The spaces preceding the closing brace are retained
Reproduces without extensions: Yes
The text was updated successfully, but these errors were encountered: