The most flexible alignment plugin for Sublime Text 2/3
This plugin is inspired by the excellent VIM plugin, tabular.
Note: ST2 support is deprecated and moved to ST2 branch. However, you are still able to install AlignTab to ST2 via Package Control.
- Align using regular expression
- Custom spacing, padding and justification.
- Smart detection for alignment if no lines are selected
- Multiple cursors support
- Table mode and Live preview mode
- Predefined alignment
- Open
AlignTabin Command PaletteC+Shift+pand enterregex/optionin the input panel - The option controls column justification, pedding and maxinum number of splits.
- For example:
c2r3f1- first column is centered followed by 2 spaces
- second coumn is right-flushed followed by 3 spaces
- only the first delimiter is matched
-
Use non-capturing parenthese
(?:regex)instread of capturing parenthese. -
Delimiter is also treated as a column.
For example,=/rclmeans the the column before=will be right-justifed and the column after=will be left-justified. And=will be centered (however, it doesn't matter as=is of length 1). -
The option for alignment cycles through the columns.
For example,regex/rlmeans all odd columns will be right-justified and all even columns will be left-justified. -
the symbol
*repeats the preceeding justification flags.
For exampler*3equalsrrr, and(cr3)*2equalscr3cr3. -
Default option is
l1f0.- All columns are left-justified.
- A space is added after each column.
- All matched delimiters are aligned.
Some simple examples. You can also contribute your examples there. Examples
For frequent patterns, put the following keybind in your user keybinds file. (Remember to change the key and regex.)
//align =
{
"keys": ["super+shift+a"], "command": "align_tab",
"args" : {"user_input" : "=/f"}
}
or syntex specific keybind.
// latex align keybind, to align & and \\, but not \&
{
"keys": ["super+shift+a"], "command": "align_tab",
"args" : {"user_input" : "(?<!\\\\)&|\\\\\\\\"},
"context":[
{ "key": "selector", "operator": "equal", "operand": "text.tex.latex" }
]
}
To make it easier to remember complex patterns, you can save them in a dictionary in the settings file. Use the name as key and the regex as value. These patterns are included in the default file:
"named_patterns": {
"first_equal" : "=/f",
"first_comma" : ",/f",
"first_colon" : ":/f",
"all_and" : "&",
"all_bar" : "\\|",
"all_space" : "\\s*/l1l0"
}
You then just use the name instead of the pattern in the input field.
To edit the patterns, go to Perferences -> Package Settings -> AlignTab -> Settings.
To define new item in the context menu, go to Perferences -> Package Settings -> AlignTab -> Context Menu and add
[
{"caption" : "-"},
{
"id": "aligntab",
"caption": "Align By",
"children": [
{
"caption" : "{",
"command" : "align_tab",
"args" : {"user_input" : "\\{"}
}
]
}
]
AlignTab supoorts CJK characters, but you have to choose a correct font face and font size.
To my knowledge, MinCho works on all Chinese, Japanese and Korean.
AlignTab is licensed under the MIT License.



