|
|
Comments and Discussions
|
|
 |

|
So nice! It's very useful. Thanks!
Raluca
|
|
|
|

|
in .net studio 2005 , for c#, if you go to the very bottom of the file and remove closing } and type it again - it will reformat code nicely.
so it maybe makes sense to write similar macro to run for all files in the project
|
|
|
|

|
This is the sweetest thing I've ever seen. thanks!
|
|
|
|

|
Hj,
The tool is very nice and usefull , especially when different users with different styles are dealing with the same code.
I tried the tool, and therefore I would like to add a comment.
Some people are writing code by using " { " on a different line , and others put " { " on the same line: Sample :
for
{
}
or
for {
}
Me am intereseted in having on the same line , and here rise my question: It is possible to make it configurable to support both variants ?
Best Regards
Victor Cuteanu
victor_cutty@yahoo.com
|
|
|
|

|
Hi!
First of all, thanks for this really nice macro that I have been using
regurlarly since my days with VC6.
To fix the problem of formatting e.g. "i--" as "i - -" I changed the
beginning of the FixOperator function as follows:
Private Sub FixOperator(ByVal strOperator As String, ByVal nLen As Integer, Optional ByVal bCheckBrace As Boolean = False)
Dim strLastPos As String = InitializePosition()
Dim selection As TextSelection = ActiveDocument.Selection
Dim strMatch As String
If strOperator.Equals("-") Then
strMatch = "[A-Za-z0-9\)_\]]" & strOperator & "[A-Za-z0-9\(_\*""'&]"
Else
strMatch = "[A-Za-z0-9\)_\]]" & strOperator & "[A-Za-z0-9\(_\*""'&\-]"
End If
While selection.FindText(strMatch, vsFindOptions.vsFindOptionsRegularExpression) And _
GetCurrentPosition(strLastPos)
selection.CharLeft()
If Not ShouldIgnore() Then
selection.FindText(strMatch, vsFindOptions.vsFindOptionsRegularExpression)
...
...
...
...
End Sub
I actually don't know Basic but it worked for me and I hope it works
for others.
Andreas Schoenle
mailto:aschoen@_remove_gwdg.de
|
|
|
|

|
the following is a reformatted code segment with the macro, obviously more reformatting is needed:
double espl1(double *x, double *y, int n, double *dy, double *ddy,
double *t, int m, double *z, double *dz, double *ddz)
{
int i, j;
double h0, h1, alpha, beta, g, *s;
s = new double [n];
s[0] = dy[0];
dy[0] = 0.0;
h0 = x[1] - x[0];
for (j = 1; j <= n - 2; j++)
{
h1 = x[j + 1] - x[j];
alpha = h0/ (h0 + h1);
beta = (1.0 - alpha)* (y[j] - y[j - 1])/h0;
beta = 3.0* (beta + alpha* (y[j + 1] - y[j])/h1);
dy[j]=-alpha/ (2.0+ (1.0 - alpha)*dy[j - 1]);
s[j] = (beta- (1.0 - alpha)*s[j - 1]);
s[j] = s[j]/ (2.0+ (1.0 - alpha)*dy[j - 1]);
h0 = h1;
}
for (j = n - 2; j >= 0; j--)
dy[j] = dy[j]*dy[j + 1] + s[j];
for (j = 0; j <= n - 2; j++)
s[j] = x[j + 1] - x[j];
for (j = 0; j <= n - 2; j++)
{
h1 = s[j]*s[j];
ddy[j] = 6.0* (y[j + 1] - y[j])/h1 - 2.0* (2.0*dy[j] + dy[j + 1])/s[j];
}
h1 = s[n - 2]*s[n - 2];
ddy[n - 1] = 6.* (y[n - 2] - y[n - 1])/h1 + 2.* (2.*dy[n - 1] + dy[n - 2])/s[n - 2];
g = 0.0;
for (i = 0; i <= n - 2; i++)
{
h1 = 0.5*s[i]* (y[i] + y[i + 1]);
h1 = h1 - s[i]*s[i]*s[i]* (ddy[i] + ddy[i + 1])/24.0;
g = g + h1;
}
for (j = 0; j <= m - 1; j++)
{
if (t[j] >= x[n - 1])
i = n - 2;
else
{
i = 0;
while (t[j]>x[i + 1]) i = i + 1;
}
h1 = (x[i + 1] - t[j])/s[i];
h0 = h1*h1;
z[j] = (3.0*h0 - 2.0*h0*h1)*y[i];
z[j] = z[j] + s[i]* (h0 - h0*h1)*dy[i];
dz[j] = 6.0* (h0 - h1)*y[i]/s[i];
dz[j] = dz[j]+ (3.0*h0 - 2.0*h1)*dy[i];
ddz[j] = (6.0 - 12.0*h1)*y[i]/ (s[i]*s[i]);
ddz[j] = ddz[j]+ (2.0 - 6.0*h1)*dy[i]/s[i];
h1 = (t[j] - x[i])/s[i];
h0 = h1*h1;
z[j] = z[j]+ (3.0*h0 - 2.0*h0*h1)*y[i + 1];
z[j] = z[j] - s[i]* (h0 - h0*h1)*dy[i + 1];
dz[j] = dz[j] - 6.0* (h0 - h1)*y[i + 1]/s[i];
dz[j] = dz[j]+ (3.0*h0 - 2.0*h1)*dy[i + 1];
ddz[j] = ddz[j]+ (6.0 - 12.0*h1)*y[i + 1]/ (s[i]*s[i]);
ddz[j] = ddz[j]- (2.0 - 6.0*h1)*dy[i + 1]/s[i];
}
if(s) delete [] s;
return (g);
}
Thanks any way.
|
|
|
|

|
I ran this on my C# code and it pulled this pragma to column 0. I don't want it to move. What can I do?
|
|
|
|

|
Annoying, isn't it?
That happens as a result of the call to "SmartIndent" on line 231. Comment that out and the problem won't occur.
Regards,
Alvaro
I cannot take anything the Bush administration does seriously. The corruption, the cynical disregard for humanity, the cronyism and incompetence, all wrapped in a slimey flag of ultra-marketed nationalism repulses me. -- consdubya from fark.com.
|
|
|
|

|
http://sourceforge.net/projects/astyle/[^]
I have used it for a very long time (C++)and works perfectly.If you need a shortcut, you can declare it as a tool in MSVC IDE with proper parameters, and create a macro to activate it.
Sorry if I offended anyone.
|
|
|
|

|
Thanks. But an even better alternative is to upgrade to VS.NET 2005.
Regards,
Alvaro
I cannot take anything the Bush administration does seriously. The corruption, the cynical disregard for humanity, the cronyism and incompetence, all wrapped in a slimey flag of ultra-marketed nationalism repulses me. -- consdubya from fark.com.
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
|
A great macro for reformatting C++ source code.
| Type | Article |
| Licence | |
| First Posted | 16 Nov 1999 |
| Views | 257,443 |
| Bookmarked | 77 times |
|
|