I suggest you ...

Do not indent #region with code

In C# the #region's follow the code in indentation. I think this is wrong, as they are not a part of the code, and should stay aside - just like they do it in Visual Basic.
I find the C# #region's too obtrusive. Please, change the behaviour, so they are left-aligned in the editor window, both when folded and unfolded.

65 votes
Vote
Sign in
(thinking…)
Sign in with: facebook google
Signed in as (Sign out)
You have left! (?) (thinking…)
Mikhail shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

12 comments

Sign in
(thinking…)
Sign in with: facebook google
Signed in as (Sign out)
Submitting...
  • Josef commented  ·   ·  Flag as inappropriate

    Would be a real beloved feature. As @Stephen says, should be configurable ...

  • Stephen Elms commented  ·   ·  Flag as inappropriate

    C# #region indentation should be a user configurable setting available under Tools > Options > Text Editor > C# > Code Style > Formatting > Indentation

  • Wolfgang commented  ·   ·  Flag as inappropriate

    I agree 100%. #region is not part of the code and with #region indented the code is harder to read. That really annoys me EVERYTIME I see it, so there should be an option, so that we can decide that individually for ourselves.

  • Data Juggler commented  ·   ·  Flag as inappropriate

    I think Regions should be indented, and VS 2015 brought in a bug that VS 2013 or below didn't have.

    Now every time I paste with an indented region, even with all formatted options turned off, I have to push my code back to the right.

  • Stuart commented  ·   ·  Flag as inappropriate

    Agreed, I would love this feature to be implemented. #region in line with code just looks messy.

  • Richard P commented  ·   ·  Flag as inappropriate

    I so agree, the way VB.Net treats the #Region tags is far more readable - they're not part of the code so why indent them with the code?!

  • zeromus commented  ·   ·  Flag as inappropriate

    There's a model for this in the C/C++ preprocessing indentation options at some point in the past 5 years. But the current behaviour I think might be a slight bit more magic than any of those options and I would hate to lose it. Anyway, I suggest you ignore this guy who thinks he knows what's best and make it an option instead.

  • Anonymous commented  ·   ·  Flag as inappropriate

    By having the #region #endregion to the far left the code is much easier to read and looks less polluted. At the least we should be able to default the alignment to wherever we like.

Feedback and Knowledge Base