skip to Main Content

Make curly braces appear as if on a new line

There is a coding standard in our company that demands the starting curly braces not to be placed on a new line.

private bool ReturnTrue() {
            return true;
}

Is there a tool or a plugin for Visual studio that would make braces appear as if they were on a new line when they are actually on the same line?

Every solution I found actually changes the code.

2

Answers


  1. I would consider discussing the code standards. The curly brace on the same line is a common standard for C/C++ code, but it’s very uncommon for C#. So maybe people just took with them what they where used to when the transition was made to C#, without considering that a new language might prefer different standards. You wouldn’t be using underscore_delimited_identifiers in C# either, would you?

    Of course, everyone (and every company) is free to use their own standards, but when one uses the same (or similar) standards than what everyone else does in that language, it will be easier to understand and/or modify code from someone else, e.g. from third-party libraries you might be using.

    Login or Signup to reply.
  2. At first my code was like this:

    enter image description here

    If you don’t want the curly braces to be on new lines try this:

    Tools=>Options=>Text Editor=>C#=>Code Style=>Formatting=>New Lines=> Uncheck the options under New line options for braces according to your own needs (I unchecked all of them) => OK

    At this time, click ctrl+k, ctrl+d.

    My code will become like this:

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search