|
|
Comments and Discussions
|
|
 |

|
Thank you very much for this nice set of macros. I always wonder how ugly my code may look to someone else. When I ran the macros, it pretty much left things intact. I do like the extra spaces after the 'if' statements, but I find it so much easier to but the parenthesis up right next to it while working. That was the only difference I noticed in my code. Thanks again!
|
|
|
|

|
Hi,
I get an Error Message when I run MakeCodeNicer during the following line:
DTE.Documents.Add("Text")
The Message: Die Vorlage "General\Text File" ist für das ausgewählte Projekt ungültig.
in german english: The Template "General\Text File" is not valid for the choosed Project.
I try to reformat C++ code. Any hints? I looked at the options, at google for the error message, in dev help and so on. No hints.
Tschoe,
Rüdiger
|
|
|
|

|
That's strange. Your current project does not allow creating Text files? Have you tried creating a Text file from the "File/New/File..." menu?
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.
|
|
|
|

|
hi Rudiger,
I m facing same problem have you found the workaround
Thnx.
|
|
|
|

|
Good morning,
if I have some deklarations like this:
BigDataTypeStruct *pSomething;
char cValue[CSV_MAX_LINE_LEN],
cLine[CSV_MAX_LINE_LEN];
long i = 0,
z = 1;
the result of reformat replaces the tabs before each line without the datatype:
BigDataTypeStruct *pSomething;
char cValue[CSV_MAX_LINE_LEN],
cLine[CSV_MAX_LINE_LEN];
long i = 0,
z = 1;
and this looks NOT nice!
In my opinion the example code of var deklaration is better readable instead the datatype on each line.
BR
Stephan
|
|
|
|
|

|
It's non-free, but there's a 14-day trial; ProFactor StyleManager - a highly configurable Visual Studio source code reformatting plugin.
|
|
|
|

|
Studio auto formatting code has a bad habit of causing blank lines to be filled
with spaces (or tabs) up to the indent level. I created a macro a long time ago
which removes this problem. It may not be the best way to do this (I don't know
the language well, but can create a quick macro and make it work). I have added
a call to this function right after the call to IndentSwitchBody, and now the
MakeCodeNicer will truely blank out the blank lines:
function PurgeNonBlankBlankLines
while ActiveDocument.Selection.FindText("^\:b+$", dsMatchRegExp)
ActiveDocument.Selection.StartOfLine dsFirstText
ActiveDocument.Selection.EndOfLine dsExtend
ActiveDocument.Selection.Delete
wend
end function
Btw, thanks for a good macro and a nice improvement over basic Alt-F8 behavior.
|
|
|
|

|
PRIVATE FUNCTION IsWithinComment DIM nCurrentLine, nCurrentColumn DIM nBeginCommentLine, nBeginCommentColumn DIM nEndCommentLine, nEndCommentColumn nCurrentLine = ActiveDocument.Selection.CurrentLine nCurrentColumn = ActiveDocument.Selection.CurrentColumn ActiveDocument.Selection.Cancel ActiveDocument.Selection.StartOfLine dsFirstText, dsExtend IsWithinComment = false IF (InStr(1, ActiveDocument.Selection, "//", vbTextCompare) > 0) THEN IsWithinComment = true nCurrentLine = nCurrentLine + 1 END IF ActiveDocument.Selection.MoveTo nCurrentLine, nCurrentColumn IF not IsWithinComment THEN ' Now look to see if we are in a c multiline comment, we do this by simply looking ' from out current position to the beginning of the file for "/*" ' ActiveDocument.Selection.FindText "\/\*", dsMatchCase + dsMatchBackward + dsMatchWord _ + dsMatchRegExp bContinue = GetCurrentPosition (strLastPos) IF bContinue THEN nBeginCommentLine = ActiveDocument.Selection.CurrentLine nEndCommentColumn = ActiveDocument.Selection.CurrentColumn ' Look forward for the matching "*/" ' ActiveDocument.Selection.FindText "\*\/", dsMatchCase + dsMatchForward + dsMatchWord _ + dsMatchRegExp nEndCommentLine = ActiveDocument.Selection.CurrentLine nEndCommentColumn = ActiveDocument.Selection.CurrentColumn IF nBeginCommentLine <= nCurrentLine and _ nBeginCommentColumn < nCurrentColumn and _ nEndCommentLine >= nCurrentLine and _ nEndCommentColumn > nCurrentColumn THEN IsWithinComment = true END IF END IF ActiveDocument.Selection.MoveTo nCurrentLine, nCurrentColumn END IF END FUNCTION ' IsWithinComment' Sean C. Hubbell
|
|
|
|

|
PRIVATE FUNCTION IsWithinComment
DIM nCurrentLine, nCurrentColumn
DIM nBeginCommentLine, nBeginCommentColumn
DIM nEndCommentLine, nEndCommentColumn
nCurrentLine = ActiveDocument.Selection.CurrentLine
nCurrentColumn = ActiveDocument.Selection.CurrentColumn
ActiveDocument.Selection.Cancel
ActiveDocument.Selection.StartOfLine dsFirstText, dsExtend
IsWithinComment = false
IF (InStr(1, ActiveDocument.Selection, "//", vbTextCompare) > 0) THEN
IsWithinComment = true
nCurrentLine = nCurrentLine + 1
END IF
ActiveDocument.Selection.MoveTo nCurrentLine, nCurrentColumn
IF not IsWithinComment THEN
' Now look to see if we are in a c multiline comment, we do this by simply looking
' from out current position to the beginning of the file for "/*" '
ActiveDocument.Selection.FindText "\/\*", dsMatchCase + dsMatchBackward + dsMatchWord _
+ dsMatchRegExp
IF bContinue THEN
nBeginCommentLine = ActiveDocument.Selection.CurrentLine
nEndCommentColumn = ActiveDocument.Selection.CurrentColumn
' Look forward for the matching "*/" '
ActiveDocument.Selection.FindText "\*\/", dsMatchCase + dsMatchForward + dsMatchWord _
+ dsMatchRegExp
nEndCommentLine = ActiveDocument.Selection.CurrentLine
nEndCommentColumn = ActiveDocument.Selection.CurrentColumn
IF nBeginCommentLine <= nCurrentLine and _
nBeginCommentColumn < nCurrentColumn and _
nEndCommentLine >= nCurrentLine and _
nEndCommentColumn > nCurrentColumn THEN
IsWithinComment = true
END IF
END IF
ActiveDocument.Selection.MoveTo nCurrentLine, nCurrentColumn
END IF
END FUNCTION ' IsWithinComment'
Sean C. Hubbell
|
|
|
|
 |
|
|
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,584 |
| Bookmarked | 77 times |
|
|