An alignment plugin for Sublime Text 2/3 -- ST version of the excellent VIM plugin, tabular.
- Align with user defined regular expression
- Custom spacing, padding and justification.
- Smart detection for alignment if no lines are selected
- Multiple cursors support
- Table mode: super efficient for editing tables
###First time user
- Predefined alignment tools can be found under the mouse menu
Align By
###Advanced user
- Open
AlignTab
in Command PaletteC+Shift+p
- The input should be in the from of
regex/option
- The option, e.g.,
c2r2f1
, controls - column justification:
r
,l
orc
- spaces after each column: the number after
r
,l
orc
- max number of delimiters: the number after
f
- Delimiter is also treated as a column.
For example,=/rcl
means 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/rl
means all odd columns will be right-justified and all even columns will be left-justified. - the symbol
*
repeats the preceeding justification flags.
For exampler*3
equalsrrr
, and(cr3)*2
equalscr3cr3
. - Default option is
l1f0
.
- All columns are left-justified.
- A space is added after each column.
- All matched delimiters are aligned.
- Do not use capturing parenthese for regular expression. Instead, use non-capturing parenthese
(?:regex)
.
###Table Mode
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"
}
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
.