How to align texts in Sublime Text 3?
The AlignTab docs or the linked examples have enough info to cover what you need.
If you highlight the original text, then Cmd + Shift + P (or Ctrl Shift P on windows) and enter AlignTab Live Preview mode, you can enter a regex and use the special rlc syntax.
The syntax is:
\s+:/r0c1l
The regex are \s+ (greater than 1 spaces) to the first :, then r0 (align right, 0 spaces), c1 (center mark with 1 padding to the right), then l (left align the remaining text). There's no need for an 'f1' at the end of the expression since the regex matches the leading spaces before your first colon (per your example).
If you had newly written text without the pre-formatting that you've already done, like:
Version: 1.4.1
Author: Ken Wheeler
Website: http://kenwheeler.github.io
Docs: http://kenwheeler.github.io/slick
Repo: http://github.com/kenwheeler/slick
Issues: http://github.com/kenwheeler/slick/issues
Then to convert to your desired format below, will be:
:/r0c1lf1
Converted below:
Version: 1.4.1
Author: Ken Wheeler
Website: http://kenwheeler.github.io
Docs: http://kenwheeler.github.io/slick
Repo: http://github.com/kenwheeler/slick
Issues: http://github.com/kenwheeler/slick/issues
This result is actually better than your original question text, because there's no leading space.
P.S. I found that the Tablular examples from the AlignTab docs to be slighty more helpful, although it doesn't represent the real implementation of AlignTab.
You can do this with AlignTab, no need for a different plugin. You just need to use the more advanced regex functionality as described on the GitHub page.
Bring up the Command Palette
(Ctrl+Shift+P on Windows or cmd+shift+P on Mac), type in "AlignTab", press enter, and type this in and hit enter:
:/r0clf1
Props to @Hank for including 0 spaces option, didn't even realize he didn't want the space.
Explanation:
- the
:
finds the colon - the
/
says okay now here come some arguments about what I want you to do with the colon - the
r
means right-justify the first column - the
0
means 0 spaces after the right column - the
c
means center the middle column (which is just the colon, so it doesn't do anything) - the
l
means left-justify the right column - the
f1
means only do this for the first match on the line