After namespace
, class
, struct
, enum
, for
, foreach
, while
, switch
, do
, using
, unchecked
and at the beginning of methods, shouldn't Visual Studio automatically include curly brackets? How to activate this feature?
Ctrl + Shift + Enter = Insert blank line below the current line. Ctrl + Space = Autocomplete using IntelliSense. Alt + Shift +arrow keys( ← , ↑ , ↓ , → ) = Select custom part of the code. Ctrl + } = Match curly braces, brackets.
In programming, curly braces (the { and } characters) are used in a variety of ways. In C/C++, they are used to signify the start and end of a series of statements. In the following expression, everything between the { and } are executed if the variable mouseDOWNinText is true. See event loop.
On English keyboards, the open bracket and close bracket are on the same key as the [ and ] (square bracket) keys, located near the Enter key. To get a curly bracket, press and hold the Shift key, then press the { or } key.
If you have Power Commands installed you can then go to the Tools->Options->Power Commands and make sure "Format Document on Save" is selected. Whenever you save the edited file the Curly Braces will be auto aligned.
With Resharper curly closing bracket adds by itself (either right away or after pressing enter). I think it's also the case for non-resharped Visual Studio but not 100% sure about that. Only opening bracket you have to write by yourself.
Currently Resharper 5.0 is free (as long as it's in beta/night build status), you just have to reinstall it every 20-30 days (but you would want to do it anyway since they tend to fix/add things). I can't code without Resharper anymore :-) It's so much time saver! Not sure what i will do when it's no longer beta ;/
Edit:
With Resharper you can even get IDE to use braces or not to use them in some cases (where it's possible). Check out this link about code formatting in Resharper.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With