Code alignment

Free

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

(63) Review
Visual Studio
2015, 2013, 2012, 2010
Download (124,339)
7/12/2015
12.0
View
E-mail Twitter del.icio.us Digg Facebook
Add to favorites
Description
Reviews (63)
Q and A (29)
Sign in to write a review
Sort by:

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

Excellent..

by Seth Morris | October 19 2014

cpmcgrath October 19 2014
| Edit |
Delete

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 |
Delete

Hi,
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 - https://github.com/cpmcgrath/codealignment/wiki/Align-by-space

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!

by David Jang in Korea | February 25 2014

Nice Job, nice tool.
For the first time, I'm writing down review here.
To write down here, I've just signed up here.
Hope to have a nice developing life :)

by Jes.Inc | December 11 2013

Please add align by tabs

cpmcgrath December 12 2013
| Edit |
Delete

Hi Jes, Here's an explanation of Tabs in Code Alignment - https://github.com/cpmcgrath/codealignment/wiki/Tabs-&-Alignment

by Fabio Armani | December 05 2013

Great. I can no longer do without it.

by SouthendRonnie | December 04 2013

by SegaWang | November 26 2013

Really perfect! My love tool~

by W.D. Stevens | October 22 2013

Excellent!!! Exactly what I've been doing manually for ages. Awesome!

cpmcgrath October 29 2013
| Edit |
Delete

Glad to hear! Thanks for the review!

by Kat_Development | October 16 2013

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


  • 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}, 
      {seven,nine,five,eight},
      {ab,b,cc,z}};
      
      Yielding:
      
      var a = { {one,three,five,b}, 
                {seven,nine,five,eight },
                {ab,b,cc,z}};
      
      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 - https://github.com/cpmcgrath/codealignment/issues/38
      
      For aligning the character after an alignment... Well, this can already be achieved with alignment chaining. If we create a very simple shortcut of...
      [^\s]
      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}, 
      {seven,nine,five,eight},
      {ab,b,cc,z}};
      
      and running the regex you suggested two messages above yields:
      
      var a = { {one,three,five,b}, 
                {seven,nine,five,eight},
                {ab,b,cc,z}};
      
      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
      [^\s]
      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
      
         kernel.Bind<IValueCalculator>().To<LinqValueCalculator>();
         kernel.Bind<IDiscountHelper>().To<DefaultDiscountHelper>();
      
      When I place my cursor anywhere on either line before the first set of parens and press 'Ctrl = [' I get:
      
         kernel.Bind<IValueCalculator>().To<LinqValueCalculator>();
         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)
      
      https://github.com/cpmcgrath/codealignment/wiki/Customise-shortcuts
      
      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..'? 
      Thanks
      
      Sanjeev
    • Hi Sanjeev,
      Keyboard shortcuts can be customised - https://github.com/cpmcgrath/codealignment/wiki/Customise-shortcuts
      
      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 :)
  • Align after public type
    3 Posts | Last post July 23, 2014
    • This is a great tool, it is going to save me a lot of time, but I am having a problem with 
      In the case where I want to align...
        public string FirstName { get; set; }        =>  public  string  FirstName { get; set; }    
        public string Surname { get; set; }          =>  public  string  Surname   { get; set; }
        public int Age { get; private set; }         =>  public  int     Age       { get; private set; }
        private Address Address { get;  set; }       =>  private Address Address   { get; set; } 
      
      Can not get automatic alignment of FirstName, Surname with Age and Address
      What I am thinking is needed is an alignment of white space separated text for N columns.
      
      Currently I only get the alignment to work by manually entering spaces.
      Using VS 2013 with code alignment tool downloaded yesterday
      
      Yes I have looked at https://github.com/cpmcgrath/codealignment/wiki/Align-by-space
      
      Thanks for this great tool!
    • Hi Pi
      
      I always format my auto properties exactly the same way you do.
      
      "Align by space" is the answer, albeit a multi-step process. In a nutshell, you're aligning each column by space, one column at a time. "Align by space" only aligns to the right of the current caret column position.
      
      I normally click somewhere near the middle of the first column, lets say the caret is now on the second line, between the 'b' and 'l' in the word "public". Hit Ctrl+=, space.
      
      Move the caret with the mouse or keyboard so that it is somewhere within the shortest word of the next column. In this case the word "int" is the shortest, so lets say the caret is now just after the 't'. Hit Ctrl+=, space.
      
      Again , move the caret to the column that is within the smallest word of the next column: "Age". Hit Ctrl+=, space.
      
      This takes a long time to read, but in practice it literally takes about four or five seconds to do align three columns. And you might have 20 lines of auto properties.
      
      Kind regards
      Michael
    • Hi Michael,
      
      Yes thank you - got it.
      Yes it is fast (once you know what you are doing).
      
      Thank You :-)
  • auto property alignment
    2 Posts | Last post May 07, 2014
    • is it possible to align
      
      public int Id { get; set; }
      public String Name { get; internal set; }
      public Dictionary<string, string> Data { get; protected set; }
      
      like
      
      public int                           Id   { get; set; }
      public String                        Name { get; internal set; }
      public Dictionary<string, string>    Data { get; protected set; }
    • Hi, Sorry about the delay.
      This can be done using "Align by Space" Check out https://github.com/cpmcgrath/codealignment/wiki/Align-by-space
  • waiting for second key of chord
    4 Posts | Last post November 27, 2013
    • How can I fix this?
      
      When I press CTRL + =, I see "waiting for second key of chord" .. 
      
    • It is possible to do this?
      
      scss:
      
      position:relative;
      top:0;
      
      align to
      
      position: relative;
      top:      0;
    • Hi Polikin. Visual Studio defines a chord as a series of key presses (like on a piano). For example to toggle "show white space" you press Ctrl E, S - when you press Ctrl E in the status bar it will say "Waiting for second key of chord"
      
      I used the same terminology for code alignment. Ctrl = activates Code alignment, then you enter the next key, for example, pressing = again will align by equals.
    • To do that alignment press Ctrl Shift =, click the options button and choose "Shortcuts"
      
      Add a shortcut, for the alignment put
      :\s*(?<x>[^\s])
      (explanation: the (?<x> identifies the part to align by,if it doesn't exist it groups at the start, the \s means white space, so it says, "align by the first non space after a colon")
      
      tick "Is Regex" and "Add Space" and use what key you assigned it to as the second key of the chord.
  • C# format document deletes all spaces
    6 Posts | Last post November 07, 2013
    • I'm using VS2013 C#.
      It's happy to alignment all the enums for me.
      But after save, all of them revert back to unalignment state...
      Then I tried Ctrl-ED, it also do the same thing...
      
      I tried to disable maybe related components include CodeMaid, VScommands, Web Essential, with no luck.
      I also tried to look for any settings that may affect this, also with no luck.
      
      I'm heavily rely on format document function too, and love to use CodeMaid cleanup/format on save.
      That means Code alignment do nothing to me!
    • Hi there,
      If you are formatting a document on save then there's little Code alignment can do.
      The purpose of Visual Studio's format is to fix the indentation, add spaces when they are missing (foo=bar to foo = bar) and to remove duplicate spaces when they are not needed.
      
      This means that it's purpose is to remove what code alignment inserts.
      
      For me, I turned off every automatic format trigger. The things it fixes were things I never did (I always indent properly, always have spaces around = signs, etc) so the only thing it did was annoy me by undoing things that I wanted to keep.
    • As to why it's auto formatting on save, I can only guess that you still have an extension enabled. The default Visual Studio behaviour does not format c# on save.
    • I still wish to use format on save.
      Sometimes I will do some lazy editing, and while saving, all of them will be corrected.
      And sometimes only because team member's code is not well formatted (cause they doesn't use format on save). I don't need to check, just use CodeMaid's "Cleanup All Code" occasionally to correct all of them.
      And wish to keep the alignment that I do purposely.
      
      If you can find out the VS setting for removing space, I can disable it.
      Or your add-in can affect the process of formatting, never to remove the spaces that code alignment inserted.
      Or you can insert a different space char, that seems the same as normal space char, and won't be remove by formatting.
      
      From now on, I can only uninstall code alignment, until you can do something to the users using Ctrl-ED/format on save.
    • "If you can find out the VS setting for removing space, I can disable it."
      No setting exists in Visual Studio
      
      "Or your add-in can affect the process of formatting, never to remove the spaces that code alignment inserted."
      There's no way to determine if extra spacing is for an aligning or a mistake - and to put it bluntly, there shouldn't be. Modifying the process is impossible, you could override it, but that's not in the scope of code alignment and again, it shouldn't be.
      
      "Or you can insert a different space char, that seems the same as normal space char, and won't be remove by formatting."
      This is not an option. If a character like that existed (And I'm not familiar enough with Unicode to say if it does or not) You'd run the risk of an editor not being able to display it properly, a compiler treating it as a meaningful character and showing an error people can't figure out - because the cause is completely hidden.
      
      The only possibility is for a separate extension which overrides the format document call, and never removes any spaces. Personally, I think such an extension would render the format command useless.
      
      If you want to use the format command and code alignment, you need to take it off the save event. The keyword in your description of why you format is SOMETIMES. On the few cases when this happens, then format your document or section.
    • Code alignment is going the extra mile; it's the opposite of the lazy option, like auto-format on save. It's about taking pride in your work and making your code beautiful to look at and easy to read. It's about helping the next guy understand your code. (And sometimes the next guy is you, two years down the track.)
      
      An auto-format tool will make your code consistent, but it will be consistently awful to look at. The only way to make really neat code is to do it yourself, which is where the Code alignment extension shines.
  • Align By Tab or Align By RegEx
    12 Posts | Last post October 18, 2013
    • Hi, good tool!
      
      I would like to see a way to 1) align by Tab (yes, I know you hate tabs) since I don't see a way to enter a tab, or 2) align by a regular expression which would seem to make the tool even more versatile.
      
      Good work.
      
    • Love the idea of allowing regular expressions. I won't implement the align by tabs directly but the align by regular expression should allow you to do that.
    • +1!
    • When the "Use IDE tab settings for alignments" is checked, the alignment ends up with mixed spaces and tabs for some reason. I wish this could produce pure tab alignment rather than mixed with spaces. Also, this yeilds JHint warnings.
    • +1 for tab support; it should honor the vs setting not impose a personal preference on the users. I wouldn't be permitted to commit space-aligned code so cant use.
    • There is support for tabs via the "Use IDE tab settings." This is not on by default because lots of users requested it. They saw tabs was used for indentation, while spaces should be used for alignment.
      
      Personally, I believe that the basic idea of tabs conflicts with aligning code. A tab has no true size, if you align with tabs then someone else reads the code and they display at a different tab size, then there is a very good chance the code won't be aligned for them. This is a conflict in the very core concepts. Tabs are about allowing individual developers to view the code how they want. Alignment is about specifying exactly how it should be displayed.
      The only way to assure it stays the same is to make sure everybody uses the same size tabs in which case, why bother with tabs at all?
    • I can't believe some companies insist on tabs. If I was in a job interview and the interviewer told me that, I'd say, "Thanks for your time, but this job isn't for me." It's not just about tabs; a rule like would mean the company has lots of other terrible policies, too.
      
      A millimetre is always a millimetre. One space is always one character wide. How many characters is a tab? 2? 4? 8? Tabs really only work properly if everyone uses the same tab size. Which kind of defeats the purpose.
      
      What if your boss said, "From now on set your tab size to seven, my favourite number. It's the number of 'completion' and I was born on the 7th, ya know."
      
      Seriously: Tabs Are Evil.™
    • Thank you for your comment cpmcgrath, I didn't notice the options box! I don't believe the alignment works in tab mode though.
      
      starting with (nonsense) code:
      			1 = 1;
      			22 = 11;
      			333 = 333;
      			666666 = 666666;
      Alignment gives me:
      
      			1 	   = 1;
      			22 	   = 11;
      			333    = 333;
      			666666 = 666666;
      
      whereas I believe it should be: (dependant upon tab-size setting of course)
      			1		= 1;
      			22		= 11;
      			333		= 333;
      			666666	= 666666;
      
      i.e., the alignment seems to be achieved by inserting a mix of tabs and spaces, rather than just tabs.
    • I get what you're saying, and I'm sure there are a lot of people who agree with you. But I think there's as many people who would say the exact opposite.
      
      It could be an option but I'm very reluctant to add anything new about tabs, as I've said tabs and alignments on a fundamental level does not make sense. As such adding new features for tabs adds little value, and I'd prefer to spend my time on bigger things.
      
      Code alignment is open source, and if someone submitted a patch for this, and I was happy with the implementation I would add it to the project.
      
      I've expanded on my reasons above here - https://github.com/cpmcgrath/codealignment/wiki/Tabs-&-Alignment
      
      I strongly recommend reading it, and reconsidering the reasons why you prefer to align with tabs.
      
      You said that your team has standardised on tabs. Do you all use the same tab size? Because if you don't, then your alignments won't be aligned for everyone - if you use spaces they will.
      
      Chris.
    • Hi, thanks for replying. I have read the reasons but tbh I don't get excited about the tab vs spaces debate, I stopped taking on theological code formatting debates many years ago, nobody wins when the coding evangelicals are in the room – there is no wrong or right way, just different ways. That said, I think it should either use tabs or spaces – not a mixture of both. I've worked in software for a long time (decades now!) and have yet to meet the coder who starts aligning his equals with tabs but finishes the alignment with spaces. Just reflecting on my experience, I appreciate you see things differently.
      
      (Yes, tab sizes are defined in our coding standards btw)
      
      My own personal opinion is I don’t care what the standard is, as long as it can be automated. Life’s too short to worry about how many times you hit the tab button (or space-bar * 2/4/8 if you're a 'space cowboy').
    • The case for using both isn't so much I want to use tabs and spaces, but this is where I want them to align at. I'll occasionally use the tool know that the furthest thing I want to align by is in the middle of a word - I don't want the word split into two.
      
      And it's actually a much harder change than it would seem. To insert an extra tab instead of those spaces, yeah that's easy. But then there's the issue of should it remove spaces (you write a = x not a\t= x. Should it just be a \t= x?), there's again arguments one way and the other.
      
      And currently Code Alignment never deletes anything (Though many people, myself included, want https://github.com/cpmcgrath/codealignment/issues/12) So it will require figuring out a consistent way to do that in Sublime, Notepad++ and Visual Studio.
    • I've created a github issue for this. Please use the issue to discuss the issue instead of here.
      
      https://github.com/cpmcgrath/codealignment/issues/24
  • Align by space and quoted strings
    3 Posts | Last post September 26, 2013
    • There doesn't appear to be a way to use align by space to line up the MyEnum.blah statements in something like this.
      
      Frobinate(0, 100, "Cat", MyEnum.Item100));
      Frobinate(8, 110, "Mouse", MyEnum.Item110));
      Frobinate(9, 111, "Dog", MyEnum.Item111));
      Frobinate(10, 200, "Rabbit", MyEnum.Item200));
      Frobinate(11, 201, "Fox", MyEnum.Item201));
      Frobinate(20, 233, "Polar Bear", MyEnum.Item233));
      
      Depending on where I put the cursor I get something like this:
      Frobinate(0,  100, "Cat",    MyEnum.Item100));
      Frobinate(8,  110, "Mouse",  MyEnum.Item110));
      Frobinate(9,  111, "Dog",    MyEnum.Item111));
      Frobinate(10, 200, "Rabbit", MyEnum.Item200));
      Frobinate(11, 201, "Fox",    MyEnum.Item201));
      Frobinate(20, 233, "Polar    Bear", MyEnum.Item233));
      
      or this:
      Frobinate(0,  100, "Cat", MyEnum.Item100));
      Frobinate(8,  110, "Mouse",      MyEnum.Item110));
      Frobinate(9,  111, "Dog", MyEnum.Item111));
      Frobinate(10, 200, "Rabbit",     MyEnum.Item200));
      Frobinate(11, 201, "Fox", MyEnum.Item201));
      Frobinate(20, 233, "Polar Bear", MyEnum.Item233));
      
      What I want is:
      Frobinate(0,  100, "Cat",        MyEnum.Item100));
      Frobinate(8,  110, "Mouse",      MyEnum.Item110));
      Frobinate(9,  111, "Dog",        MyEnum.Item111));
      Frobinate(10, 200, "Rabbit",     MyEnum.Item200));
      Frobinate(11, 201, "Fox",        MyEnum.Item201));
      Frobinate(20, 233, "Polar Bear", MyEnum.Item233));
      
      Which I think is either dependent on being able to reject spaces inside a quoted string; or being able to do smarter alignment off the commas.
      
      Align by caret using hte comma comes closest; but aligning by putting space in front of the comma instead of after it looks really weird.
      
      ex
      Frobinate(0 , 100, "Cat"       , MyEnum.Item100));
      Frobinate(8 , 110, "Mouse"     , MyEnum.Item110));
      Frobinate(9 , 111, "Dog"       , MyEnum.Item111));
      Frobinate(10, 200, "Rabbit"    , MyEnum.Item200));
      Frobinate(11, 201, "Fox"       , MyEnum.Item201));
      Frobinate(20, 233, "Polar Bear", MyEnum.Item233));
    • Thanks for the question,
      Sorry about the delay, I normally get a notification when someone posts, for some reason I didn't get one.
      
      This can be achieved with a regex...
      ,\s*(?<x>[^\s])
      
      If you look at the align by space, it's very similar. The difference is the comma at the beginning, and * instead of + because you still want to align if there is no space between the , and the word.
      
      With regexes if you include a group with the name x that's where the alignment happens. So this regex say
      find a comma, skip the spaces and align by the first non-space.
      
      I recommend going into the code alignment options and assigning it as a shortcut for Comma. (Tick all the boxes too)
    • In case anyone else is wondering how to easily do the alignment Dan wants, I think the easiest way would be to do the first two columns with 'align by space', then 'align by string' and type "My".
      
      'Align by space' honours the current caret position, so you would first set your caret somewhere near the open bracket, then move it over to the next column, e.g. 100, hit Ctrl+=, space. Then Ctrl+Shift+= to show the Enter String To Align dialog.
1 - 10 of 29 Items