Shadow-Align READMEThis extension allows adjacent lines to be aligned on the basis of a regular expression and a group array of characters. Features
There are two ways to use this extension. A simple mode and an advanced one Simple modeWe can take a simple example to understand how it works.
The following sample of code is the source we need to format.
The regular expression that can match the lines can be like this :
Then after matching the lines, we need to define how to split, here we split on the = sign , then on the ; mark
The result will be
The full configuration will be like this :
You can specify several filter, they will be apply to the selected lines Advanced modeWe can now take another sample of code, that cannot be formatted by the simple approach.
We need to define our regular expression to match the lines. But the strategy is a little bit different this time. We will not define how to split each line. We will capture each group of a line and then aligne them. Let's start with the regular expression
We have defined 4 named groups. variable, operator, assignment, and end. Now instead of specifying the group of character to split by, we will just set all group names.
The result will be this one :
This result can be enough. But maybe, if we want to be a little fussy, we will want to align the operators based on the equal sign, so on the right. To do that, we can add some information to the group name. Just adding the direction -> after the name, separated by a pipe.
The result will be this one :
Same for all the numbers ? Easy ...
Possible values are : ["<-", "--", "->"] Full configuration sample :
UsageFirst, select a bunch of lines to format, press Alt+Shift+A Extension SettingsThis extension contributes the following settings:
Release NotesTBD
1.0.6 (current version)Added alignment for a specific column 1.0.5Added a way to split based on regex named groups 1.0.4Updated readme 1.0.3Minor fixes 1.0.0Initial release of shadow-align |