-
Notifications
You must be signed in to change notification settings - Fork 55
Aligning using Regular expressions
When aligning by string you have the option to use regular expressions. This is standard regular expressions, so please google or bing if you need a tutorial on regular expressions - they'll do a much better job explaining them than I can.
Like all alignments, you align the first item that matches the regex on each line. Using regexes gives you one more power - You can say WHERE to align.
For example, let's say you want to align the first non space after a comma. The regex to find this would be
,\s*[^\s]
But aligning by that would align every comma - not what you want. To handle this you can use a special group name - x - to specify where in the match you should align...
,\s*(?<x>[^\s])
You can also set the regex flag in the Shortcuts option screen
There are 2 special group names - insert and compare (note: x is the same as compare) As you can imagine insert is where the spaces get added, and compare is used for figuring out how many spaces are needed.
If compare is used but insert is not, the spaces will be inserted at the compare location. By convention, in this case you should use x
To see how to use these check out the Right Align tutorial