The most flexible alignment plugin for Sublime Text 3. This plugin is inspired by the excellent VIM plugin, tabular.
ST2 support is deprecated but however, it is still possible to install AlignTab on ST2 via Package Control.
AlignTab
in Command Palette C+Shift+p
and enter the input in the form of <regex>/<option>
.([rlc][0-9]*)*(f[0-9]*)?
.r
, c
or l
determine how many spaces will be added after columns and the number after f
controls how many matches will be made based <regex>
.c2r3f1
means
[rlc]
is omitted, 1 space will be added after each column.f
is omitted, only the first match will be used.l1f0
will be used. It means:
(?:regex)
instread of capturing parenthese.=/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).regex/rl
means all odd columns will be right-justified and all even columns will be left-justified.*
repeats the preceeding justification flags.
r*3
equals rrr
, and (cr3)*2
equals cr3cr3
.r
, c
and l
, there is a new u
flag which stands for "unjustified".Hit ESC or use the command AlignTab: Exit Table Mode
to exit table mode.
Some simple examples. You can also contribute your examples there.
If you are interested in getting a keybind for live preview mode, add the following in your user keybinds file.
{
"keys": ["super+shift+a"], "command": "align_tab",
"args" : {"live_preview" : true}
}
For frequent patterns, you can consider the following in your user keybinds file. Change the keybind and the user_input
for your purpose.
//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. To edit the patterns, launch Preferences: AlignTab Settings
. Use the name as key and the regex as value. For examples,
"named_patterns": {
"eq" : "=/f",
// right hand side could also be an array of inputs
"ifthen" : ["=/f", "\\?/f", ":/f"]
}
You then just use the name instead of the pattern in the input field.
To define new item in the context menu, launch Preferences: AlignTab Context Menu
and add, for example
[
{"caption" : "-"},
{
"id": "aligntab",
"caption": "AlignTab",
"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.