Outlining or tab(ing) of conditional compiling code
Hi there,
when conditional compling is used in Visual Basic in VS 2005 the edior places the conditional compiling commands on the far left. This makes the reading of the code not easy especially if you use a lot of conditional compiling in loops.
Is it possible in Visual Basic within VS 2005 either to collaps the conditional compiling code automatically or to set the tabing of the conditinal compiling code so that it behaves like e.g. a for ... next or if ... endif statement.
E.g:
How it is now:
For i = 1 to 100
xx += i
#if DebugLevel > 1
MyLogFile.WriteLine(i.ToString)
#endif
xx = xx + xx^2
xx -+ i^0.5
Next i
How i want it:
For i = 1 to 100
xx += i
#if DebugLevel > 1
MyLogFile.WriteLine(i.ToString)
#endif
xx = xx + xx^2
xx -+ i^0.5
Next i
OR:
For i = 1 to 100
xx += i
...
xx = xx + xx^2
xx -+ i^0.5
Next i
Thanks a lot
Chris
The short answer is "no". For whatever design reason, directives always appear in the far left. Even if you turn all auto tabbing off so that you can control your own tabbing, VS puts the directives back to the far left.
A few suggestions:
1) If these are primarily around MyLogFile.Writeline, you could minimize how many of these you have to see by moving the check to a subroutine that then calls the MyLogFile.WriteLine. This won't take care of your issue, but it will help you to see it less.
2) Create your own #Region entries around them so that you can collapse them. If the code you are using for this is very similar, you could put the region and the entire code block in one snippet. Then you can write the code by only typing three characters.
Hope this helps ...
Hi Deborah,
thanks for the help.
Unfortunately you are not allowed to put #region commands within function or subs, so the idea is good but VS2005 has no #region alternative for use within functions/subs. (As far as I am aware of.)
In addition I thought about changing the color of the preprocessor keywords BUT unfortunately the color doesn't change!! The color changes if you change the Keyword color. This means that the preprocessor keywords belong (for coloring) in the same group as the "normal" keywords.
As we all know microsofts programms are good but unfortunately they are not excellent!!
Chris