Alignment Macro for Visual Studio 2003/2005

Posted by OmegaMan at September 13, 2006

Category: Macros, Visual Studio

Tags: ,


In all of my editors I have used, I have always written a macro to align equal signs in code. For me code has to be aesthetically pleasing and this process helps that by making the equal signs as well as other items line up.

The macro purpose is to align target text on the current and following lines looking for the text until it can no longer find it. At that point it stops, calculates which point is the farthest out and then moves all the other lines to that location.

There are actually two macros, one to only align just = signs and the other which asks for target text to align.

Equal Before
Any Before
Any Ask
There are actually two macros in this package for extra flexibility. Besides just aligning equal signs…the other macro will align anything. To do that it will prompt the user as to what to align. That can be either one character or a word or phrase.
Any Ask
Equal After Any After

  • Macro starts at current text editing position.
  • Tabs in document may interfer with calculation. If that is the case remove tabs or make sure they are evenly placed for all lines in question.
  • There are two public macros in this package (Align and AlignIt). Its best to assign them to similar keystrokes like Alt-F10 and Ctrl-Shift-F10.
  • This is a non-destructive macro, it will not delete lines or move items to other lines.
  • Once it cannot find the target text it will stop.
  • Download is in the form of a zip file which contains the vb code and a readme. There should not be viruses…but it is always good to check.


Align VB Macro for VS 2003/05 in Zip


Leave a comment

(required) (will not be published)

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  • Recent Comments

    Thanks for this simple yet delightful code....
    Hey guys I'm having the same problem as Netanel KL { “Error HRESUL...
    Soluciono el problema con el primero (First step solved it for me)....
    Thank you! I was looking for this. You save my day!...
    Thank you! This was a big help. My requirement was a little differen...
    Thanks, after a small path adjustment it worked for Visual Studio 2015...
    Good call!...
    Thank you .. this helped...
    How about when you have a long string with no space? I tried it and it...
    Thank you, I ran into this same issues with Visual Studio 2015 after i...