1

If I am writing some code in Visual Studio,

while(true)
{
    if (foo == bar)
       MessageBox.Show("ASDF");
}

And I want the code to only display the messagebox when the application is running in Debug mode, I would write #if DEBUG, #endif. But Visual studio doesn't automatically tab the # operator so it is written like this:

while(true)
{
    if (foo == bar)
#if DEBUG
    MessageBox.Show("ASDF");
#endif
}

Having to manually indent any lines that has # is annoying. How do I make visual studio to automatically tab # operators? I am using VS2010

radbyx
  • 9,352
  • 21
  • 84
  • 127
TtT23
  • 6,876
  • 34
  • 103
  • 174
  • why you want to show message box in debug mode ? – Sunny Sep 05 '12 at 05:07
  • The above example is an entirely hypothetical code that is absolutely good for nothing. Please focus on the indentation part.. it's purely an issue related to the IDE – TtT23 Sep 05 '12 at 05:07
  • I hope this is merely a result of coming up with a simplified example, but in the `!DEBUG` case, you have invalid code. –  Sep 05 '12 at 05:17

1 Answers1

2

To my knowledge there is no built-in way to adjust this tabbing.

Note: please consider conditional attribute on methods instead as shown here

public class Trace 
{ 
  [Conditional("DEBUG")] 
  public static void Message(string traceMessage) 
  { 
    Console.WriteLine("[TRACE] - " + traceMessage); 
  } 
} 
Alexei Levenkov
  • 98,904
  • 14
  • 127
  • 179