Code alignment


Code alignment helps you present your code beautifully, enhancing clarity and readability.

(70) Review
Visual Studio
2015, 2013, 2012, 2010
Download (161,972)
E-mail Twitter Digg Facebook
Add to favorites
Reviews (70)
Q and A (35)
Sign in to write a review
Sort by:

by Jason E. Gross | October 18 2016

I appreciate the convenience - I would like to see a few options

1. Integrate with the context (right-click) menu on the page, so that it'll code-align my current selection. right-click > Code Align > ...list of alignment-by choices.

That'd be nifty.

Secondly, an option to add more to it? I'd like to align by other things without always having to deal with a dialog-box.

First one I'd love, second one - eh, it'd be neat.

by Liviu U | August 24 2016

It is ok, but it doesn't work for initialization code, where it might be very useful too

new A()
X = 1,
ABC = 2

Errors in console:

(1,35): error CS1002: ; expected
(1,35): error CS7017: Member definition, statement, or end-of-file expected
(2,50): error CS1002: ; expected
(2,50): error CS7017: Member definition, statement, or end-of-file expected
(3,56): error CS1002: ; expected
+ additional 11 errors


cpmcgrath August 25 2016
| Edit |

Sorry, I'm not sure what you're referring too. Code Alignment works perfectly with Initialization code - it's completely language independent.
The errors seem to imply you didn't put a semicolon after your brace.
If you'd like to provide more details at I'll see if I can help you out.

by tzengshinfu | August 03 2016

by Sidney Akers | March 25 2016

The learning curve is a little steep (mainly figuring out the right characters to get your code the way you want), But once you've got that down, this has got to be hands down one of my FAVORITE extensions for VS

by Amadare | February 06 2016

Great tool to prettify your code!

by ReisorDev | January 14 2016

by Rodrigo Stuchi | September 30 2015

Great tool, use also in notepad++.

by yavital | July 06 2015

Chris. well done, works as I expected. Thanks. Worth mentioning the align by space and where to place cursor when aligning by space is used.

by Ken Cenerelli | June 13 2015

by Aditya Wardhana | February 26 2015

by Ryan Knuth | February 13 2015

So good! I have it for both VS and NotePad++. Will definitely donate :)

by RJM123 | February 03 2015

by casterle | January 27 2015

I've been using codealignment for some time now; hard to believe that I hadn't reviewed it until now.

Excellent product! If everyone used it, code maintenance would be much easier.

by JoseMigu3l | November 18 2014


by Seth Morris | October 19 2014

cpmcgrath October 19 2014
| Edit |

Thanks for the rating! Much Appreciated

by flybentley | September 08 2014

Poor alignment capability.
For example, when you align by ',' character you would expect it to align by all ',' characters.
In fact it just aligns by the first character.

cpmcgrath September 21 2014
| Edit |

Sorry about the delay responding. The fact is sometimes you want to align all commas and sometimes you only want to align one. In my experience one is more common.

To align multiple ones you can use the "Align from caret" option -

In version 10 I've also introduced "Alignment Chaining". I'll write something up about it soon, but basically if you have align by comma assigned to ctrl = press ctrl = keep holding ctrl and tap , a few times. This gives you complete control, and is super fast. If there's a colon you want to align by in the middle of the commas, then you can tap ,,;,,

by 3.1415926535 | July 20 2014

Thanks for this great tool!
This is going to save soooo much time.
I have been doing this manually for the last 100 years (OK it feels like that long).
Most other developers I have worked with could see value in formatting the code, but are far too lazy to do it manually.
This should be a standard part of VS so that all of the new programmers just use it as the standard, rather than the current "pretty awful print" that should be called code mangler!
Now no reason to accept poor quality code formatting at your next code review!

by Jeff Robison | May 31 2014

by Piotr Kula | April 15 2014

SO many years of pressing space bar to align code are over! Sometimes you just need this tool for mapping properties left and right for database saves. and the equals or space align is proper job!! Thanks man!

by AD_VS | April 01 2014

Brother, You are a Hero!

1 - 20 of 70 Items   
Sign in to start a discussion

  • Right aligment
    1 Posts | Last post August 26, 2016
    • How to align by Command but with right alignment
      private GetStatusCommand m_CommandGetStatus;
      private SetSeasoningStepsCountCommand m_CommandSetSeasoningStepsCount
      private              GetStatusCommand m_CommandGetStatus;
      private SetSeasoningStepsCountCommand m_CommandSetSeasoningStepsCount
      if I align by Command I get 
      private GetStatus             Command m_CommandGetStatus;
      private SetSeasoningStepsCountCommand m_CommandSetSeasoningStepsCount
  • Aligning with type modifiers
    2 Posts | Last post June 03, 2016
    • Hello,
      Thank you for the great tool!  One issue I'm having is with struct definitions that include type modifiers (unsigned int, for example).  Do you have a suggestion on how to quickly align the variable names in this struct?  Aligning by spaces does not accomplish exactly what I'd like.
      typedef struct{
         double a;
         unsigned int b;
         float c;
      I would like to obtain:
      typedef struct{
         double       a;
         unsigned int b;
         float        c;
    • Looks like I answered my own question.  You can align to the semicolon at the end using the regular expression
      I based this on your example here:
  • User tabs instead of spaces
    2 Posts | Last post April 18, 2016
    • Is it possible to use tabs instead of spaces ?
    • Hi, Sorry for my late reply.
      There's an option in the settings to use the IDE tab settings. My write up on Tabs is here -
  • Code Alignment is broken in VS2015 Update 2
    2 Posts | Last post April 13, 2016
    • The controls and menu items are still there, but none of them work. I tried to download and reinstall, but the installer doesn't recognize that I have VS2015 so it's not an option. Is there something I can do to re-enable the tool? It's one of my favorite tools and I miss it.
    • After I installed the Untabify replacement, Code Alignment started working again. I'm not sure if that's what fixed it, but I'm a happy coder again!
  • VS Autoformatting
    3 Posts | Last post September 28, 2015
    • I just discovered your extension and am loving it, however, I find myself fighting with Visual Studio's autoformatting feature.  Is there a way to prevent visual studio  destroying all my formatting whitespace?
    • Hi,
      Are you using C# or VB?
      In C# it's pretty easy. First, whenever Visual Studio formats, you can press ctrl z to undo.
      However, you can turn the formatting off in Options, go to "Text Editor > C# > Formatting > General"
      I untick all these options.
      VB's a bit harder, It's really aggressive with its autoformat. And the option to turn it off moves depending on your version of Visual Studio!
      In Visual Studio 2013 and below, it's in 
      "Text Editor > Basic > VB Specific" and the option to untick is "Pretty listing (reformatting) of code"
      In Visual Studio 2015, the option is in  
      "Text Editor > Basic > Advanced" and the option to untick is "Pretty listing (reformatting) of code"
    • I've just found out that in Visual Studio 2015 they decided to add some additional c# triggers for auto-formatting but not give us an option to turn it off.
      From what I have seen, in certain circumstances colon and open curly brace now causes an autoformat.
      Best thing we can do is send in frowns about it.
  • Wont install on 2015
    2 Posts | Last post August 06, 2015
    • 8/6/2015 6:20:03 AM - Searching for applicable products...
      8/6/2015 6:20:03 AM - Found installed product - Microsoft Visual Studio Express 2015 for Web
      8/6/2015 6:20:03 AM - Found installed product - Global Location
      8/6/2015 6:20:03 AM - Found installed product - ssms
      8/6/2015 6:20:03 AM - VSIXInstaller.NoApplicableSKUsException: This extension is not installable on any currently installed products.
         at VSIXInstaller.App.InitializeInstall(Boolean isRepairSupported)
         at VSIXInstaller.App.InitializeInstall()
         at System.Threading.Tasks.Task.InnerInvoke()
         at System.Threading.Tasks.Task.Execute()
    • Hi,
      From the look of the error you're trying to install it on Visual Studio Express. Visual Studio Express does not support extensions.
      I recommend trying Visual Studio 2015 Community - It's much more feature packed but does have a few stricter licencing conditions.
  • Alignment options
    8 Posts | Last post February 23, 2015
    • Given the following code, I'd like to place my cursor between the two open curly braces on the first line and have the following lines align on the 2nd curly brace.
      var a = { {one,three,five,b}, 
      var a = { {one,three,five,b}, 
                {seven,nine,five,eight },
      I've assigned a key to the regex: (\{|\[|\() with 'align by caret' checked. This works well in most circumstances. but in this case it doesn't work. I believe this is because you capture the caret column and then start from that point for subsequent lines. If this is the case, an option to start from the beginning of subsequent lines would solve my problem.
      If I had an option to add a space after the aligned character (in addition to the current option to insert a space before the aligned character), I could get the following which would be even better.
      var a = { { one,three,five,b}, 
                { seven,nine,five,eight},
                { ab,b,cc,z}};
      Then, using align by comma and a regex for the closing curly brace, I could get this:
      var a = { { one,   three, five, b     }, 
                { seven, nine,  five, eight },
                { ab,    b,     cc,   z     } };
      If there's not a better way to accomplish this, is it something you'd consider adding to your 'todo' list?
    • Hi,
      Sorry about the long delay on this. I somehow managed to miss it. It's a hard one to decide if a change should be made for. I'd normally just use column marking to move the subsequent lines across.
      Alternatively you could use a regex like
      (Align the last instance of { on each line)
      without Align from caret position to achieve it.
    • I can understand that there might not be much call for this alignment feature, and your regex does the job. If you do decide to implement this option it would allow me to skip adding a new shortcut, but that's not a big deal.
      I tried to assign the macro to the backslash key (so it was near the '[' and ']' keys), but could not get it to fire. I assigned it to the 'p' key and it works as expected. Installing the 11.1 release didn't improve the situation. The issue with the backspace key may be specific to my setup.
      The option to add a space after the aligned character is something I would still find useful should you choose to implement it.
    • Hi,
      Just confirmed the backslash shortcut does not seem to work -
      For aligning the character after an alignment... Well, this can already be achieved with alignment chaining. If we create a very simple shortcut of...
      With IsRegex, and AddSpace. This shortcut simply aligns the next non-space character. We can chain this onto any other shortcut to add a space after the character of the last alignment.
    • That doesn't quite do it. Starting with this:
      var a = { {one,three,five,b}, 
      and running the regex you suggested two messages above yields:
      var a = { {one,three,five,b}, 
      which is close to what I'm trying to accomplish.
      Chaining the short regex above yields:
      var a = { {one,three,five,b}, 
              { seven,nine,five,eight},
              { ab,b,cc,z}};
      What I'm after is this:
      var a = { { one,three,five,b}, 
                { seven,nine,five,eight},
                { ab,b,cc,z}};
      I'm using a modified version of the regex you suggested on 10/31/14 to accomplish the brace alignment. Using it with the close brace version of the macro, with the 'add space' checkbox checked, I can get this:
      var a = { {one,three,five,b      }, 
                {seven,nine,five,eight },
                {ab,b,cc,z             }};
      because the 'add space' inserts the space between 'eight' and the closing brace and aligns the other braces to it. An 'add space after' would allow me to do the same thing with the opening brace.
      BTW, thank you for your excellent support!
    • Hi,
      What I'm suggesting is a two stage alignment with alignment chaining. Let's say you set '1' to 
      with IsRegex on
      then set '2' to
      with FromCaret, IsRegex & AddSpace on.
      then if you use the shortcut (keeping ctrl held the whole time) 
      Ctrl = 1 2
      then it would align the way you want.
    • Hello,
      Using the wonderful ",\s*(?<x>[^\s])" regex on Comma key with all checkboxes ON, I have great results, provided I set the cursor on first field before doing Comma, then going to next field and using Comma again...
      On your example let's start by cutting the first line on a new line like this :
      var a = { 
      { one, three, five, b },
      { seven, nine, five, eight },
      { ab, b, cc, z } };
      The you put cursor on "one" and do align by Key/Comma, then cursor on "three" and align by Key / Comma, then on "five" align by Key / Comma and you're nearly done :
      var a = { 
      { one,   three, five, b },
      { seven, nine,  five, eight },
      { ab,    b,     cc,   z } };
      The  use line select and tabify to put everything in shape.
      This wonderful "Comma" shortcut got me saved on a horrible array who looked like this :
      	UTF8name("obreve",	0x014F,	"", 1, FALSE),
      	UTF8name("ocandradeva",	0x0911,	"", 1, FALSE),
      	UTF8name("ocandragujarati",	0x0A91,	"", 1, FALSE),
      	UTF8name("ocandravowelsigndeva",	0x0949,	"", 1, FALSE),
      	UTF8name("ocandravowelsigngujarati",	0x0AC9,	"", 1, FALSE),
      	UTF8name("ocaron",	0x01D2,	"", 1, FALSE),
      	UTF8name("ocircle",	0x24DE,	"", 1, FALSE),
      and now looks like this:
      	UTF8name("ocandradeva",	                             0x0911,	         "",                        1,          FALSE),
      	UTF8name("ocandragujarati",	                         0x0A91,	         "",                        1,          FALSE),
      	UTF8name("ocandravowelsigndeva",	                 0x0949,	         "",                        1,          FALSE),
      	UTF8name("ocandravowelsigngujarati",	             0x0AC9,	         "",                        1,          FALSE),
      	UTF8name("ocaron",	                                 0x01D2,	         "",                        1,          FALSE),
      	UTF8name("ocircle",	                                 0x24DE,	         "",                        1,          FALSE),
    • By the way MSDN automatic line formatting doesn't give justice to the plugin work :-)
  • Aligning on parens
    3 Posts | Last post January 27, 2015
    • I have a macro that aligns opening parens assigned to the '[' key.
      Given the following code
      When I place my cursor anywhere on either line before the first set of parens and press 'Ctrl = [' I get:
         kernel.Bind<IDiscountHelper> ().To<DefaultDiscountHelper>();
      If I then place my cursor anywhere after the first closing paren on either line and again press 'ctrl = [' nothing happens and the parens at the end of the statements do not align.
      If, however, I chain the commands by holding the ctrl key down and pressing '= [ [' the statements align as I expect:
         kernel.Bind<IValueCalculator>().To<LinqValueCalculator>  ();
         kernel.Bind<IDiscountHelper> ().To<DefaultDiscountHelper>();
      Can you tell me why the 1st method doesn't work but the 2nd (using chaining) does?
    • Again, sorry for the late reply.
      Just checking does the shortcut have the "From caret" tick box ticked?
    • Thanks! The checkbox was not checked; checking the box fixed the problem.
  • Shift key reassignment
    3 Posts | Last post November 05, 2014
    • Since the shift key is used to restrict the alignment to 'from caret', I am unable to align by curly braces, parenthesis or other shifted characters.
      Is there a way to assign another key to this function, or to align by a shifted character?
    • Hi Casterle,
      I feel you have a misunderstanding on how code alignment works. Ctrl = Q for example won't automatically align all Qs. You have to tell it what Q means. To code alignment a key is just a key. You must map it. There's a handful of default mappings (which you can change)
      You might want to consider mapping {[ to the regex (\{|\[) which will align all instances of { or [
    • You're right, I was under a misapprehension. Thanks for clearing that up.
  • Custom command in toolbar
    3 Posts | Last post October 23, 2014
    • By default, it shows '=, ==, m_ etc' command in the toolbar, is there a way we can add custom command other than by going to 'Align by..'? 
    • Hi Sanjeev,
      Keyboard shortcuts can be customised -
      As for the toolbar, to be honest once you start using the shortcuts the toolbar it pretty useless. However, all buttons on the toolbar (except ==) points to a shortcut. So if you for example changed the M alignment to what you want, and then use another extension to change the icon. 
      But I suggest using the keyboard shortcuts.
    • Thanks :)
1 - 10 of 35 Items