blog.jj5.net (2003 to 2005)

It's called hacking..

Tue Aug 31 23:01:00 UTC+1000 2004

Categories:

Have I mentioned that I'm a MACHINE!? ;)

Below is a cool little macro I wrote for VS.NET last night. It makes my code beautiful with one keystroke (ok, two..).

Perhaps I could have done it more reliably with a regular expression..?

John.

--

Public Sub Spacify()

DTE.ExecuteCommand("Edit.Replace")

DTE.Find.FindWhat = "("

DTE.Find.ReplaceWith = "( "

DTE.Find.Target = vsFindTarget.vsFindTargetCurrentDocument

DTE.Find.MatchCase =

True

DTE.Find.MatchWholeWord =

False

DTE.Find.MatchInHiddenText =

True

DTE.Find.PatternSyntax = vsFindPatternSyntax.vsFindPatternSyntaxLiteral

DTE.Find.ResultsLocation = vsFindResultsLocation.vsFindResultsNone

DTE.Find.Action = vsFindAction.vsFindActionReplaceAll

DTE.Find.Execute()

DTE.Find.FindWhat = ")"

DTE.Find.ReplaceWith = " )"

DTE.Find.Execute()

DTE.Find.FindWhat = "( "

DTE.Find.ReplaceWith = "( "

DTE.Find.Execute()

DTE.Find.Execute()

DTE.Find.Execute()

DTE.Find.Execute()

DTE.Find.Execute()

DTE.Find.Execute()

DTE.Find.FindWhat = " )"

DTE.Find.ReplaceWith = " )"

DTE.Find.Execute()

DTE.Find.Execute()

DTE.Find.Execute()

DTE.Find.Execute()

DTE.Find.Execute()

DTE.Find.Execute()

DTE.Find.FindWhat = "( )"

DTE.Find.ReplaceWith = "()"

DTE.Find.Execute()

DTE.Windows.Item(Constants.vsWindowKindFindReplace).Close()

End Sub
Copyright © 2003-2005 John Elliot