Hack Forums
[C#] Bring "break" statement one tab back in Visual Studio - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [C#] Bring "break" statement one tab back in Visual Studio (/showthread.php?tid=5989282)



Bring "break" statement one tab back in Visual Studio - grweh3wrh - Jul 13, 2019

I know this is really stupid, but it really bothers me that the "break" keyword is tabbed one more than the "case" one:

i.imgur.com/KHdICal.png

Anyone know a plugin or something that could help me?


RE: Bring "break" statement one tab back in Visual Studio - gigajew - Jul 13, 2019

It wouldn't be right without it, because the colon serves as a type of bracket


RE: Bring "break" statement one tab back in Visual Studio - SIM-3364521 - Jul 13, 2019

i dont even understand why or what you even want but in you can actually join cases together that do the same thing:

case "Hello":
case "other Hello":
//do stuff
break;

in your case they are the same case so just write in once.
you can also merge a multiple cases together with the default case that is run whenever no other condition was met:

case "Hello":
//do stuff for hello
break;
default:
//do for every other
break;

//default can also be used as a fall through if you want to build up stuff you want to do. like a pipeline and in the switch you can choose where you want to enter:

case "do everything":
//stuff
case "some stuff but not everything":
//more stuff
default:
//this stuff is always run
break;

dont know if that answered your question but these are the common ways devs avoid to use multiple blocks or breaks

EDIT:
Sorry i got that completely wrong... but i do understand now what you mean ^^ and yes depending on your ide that is fixable :) im not sure but in vs i think i can remebmre that you are able to change intellisense and indentation options and preferences under the preferences tab... hope im not mistaken there :)


RE: Bring "break" statement one tab back in Visual Studio - Vyxn - Jul 13, 2019

Do you want your break to act as case keyword?

I mean, you want this?
Code
case "tsumino":
break;

than this?
Code
case "tsumino":
     break;



RE: Bring "break" statement one tab back in Visual Studio - Washi - Jul 14, 2019

break; is a statement and is not necessarily an end-marker of the case block in C#. For example:
PHP Code

<?php 
switch (...)
{
 
  case 0:
 
     if (...) 
 
        break;
 
     // case block continues here.
 
     break;
} 
is valid.

If you want some kind of end marker of the case block, you could add a scope instead using braces. Lots of IDEs allow you to change the default brace layout. Keep in mind you will still need the break statement.
PHP Code

<?php 
switch (...)
{
 
  case 1:
 
  {
 
     ...
 
     break;
 
  }
} 



RE: Bring "break" statement one tab back in Visual Studio - gigajew - Jul 14, 2019

You can also write it like this if you want more readability or whatever (you know, each to their own)




RE: Bring "break" statement one tab back in Visual Studio - grweh3wrh - Jul 16, 2019

(Jul 13, 2019 10:31 PM)Vyxn Wrote:  Do you want your break to act as case keyword?

I mean, you want this?
Code
         case "tsumino":
break;

than this?
Code
         case "tsumino":
    break;

Yep

(Jul 14, 2019 09:32 AM)gigajew Wrote:  You can also write it like this if you want more readability or whatever (you know, each to their own)


Oh suppose that's better.

Thank you.