AlignTab
An alignment plugin for Sublime Text using regular expression
Details
Installs
- Total 169K
- Win 100K
- Mac 43K
- Linux 27K
Nov 21 | Nov 20 | Nov 19 | Nov 18 | Nov 17 | Nov 16 | Nov 15 | Nov 14 | Nov 13 | Nov 12 | Nov 11 | Nov 10 | Nov 9 | Nov 8 | Nov 7 | Nov 6 | Nov 5 | Nov 4 | Nov 3 | Nov 2 | Nov 1 | Oct 31 | Oct 30 | Oct 29 | Oct 28 | Oct 27 | Oct 26 | Oct 25 | Oct 24 | Oct 23 | Oct 22 | Oct 21 | Oct 20 | Oct 19 | Oct 18 | Oct 17 | Oct 16 | Oct 15 | Oct 14 | Oct 13 | Oct 12 | Oct 11 | Oct 10 | Oct 9 | Oct 8 | Oct 7 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Windows | 5 | 2 | 1 | 2 | 2 | 4 | 5 | 0 | 0 | 3 | 4 | 7 | 4 | 2 | 6 | 4 | 4 | 4 | 4 | 5 | 13 | 4 | 8 | 6 | 6 | 6 | 6 | 0 | 5 | 5 | 12 | 6 | 7 | 4 | 7 | 5 | 6 | 6 | 7 | 4 | 2 | 7 | 5 | 5 | 7 | 7 |
Mac | 1 | 1 | 1 | 6 | 1 | 0 | 3 | 0 | 0 | 4 | 2 | 5 | 2 | 1 | 2 | 5 | 2 | 5 | 0 | 0 | 2 | 1 | 2 | 4 | 2 | 3 | 0 | 3 | 3 | 3 | 2 | 0 | 3 | 0 | 0 | 5 | 2 | 3 | 1 | 3 | 2 | 1 | 3 | 1 | 2 | 2 |
Linux | 0 | 2 | 0 | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 1 | 1 | 2 | 4 | 3 | 1 | 1 | 0 | 3 | 2 | 0 | 4 | 2 | 4 | 0 | 0 | 2 | 2 | 2 | 0 | 2 | 1 | 1 | 2 | 3 | 1 | 1 | 0 | 1 | 1 | 4 | 1 | 1 | 1 | 3 |
Readme
- Source
- raw.githubusercontent.com
AlignTab
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.
Features
- 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
Getting started
- If you only want simple and quick alignment, the predefined alignment will help.
More complicated usage
- Open
AlignTab
in Command PaletteC+Shift+p
and enter the input in the form of<regex>/<option>
. - To learn more about regular expression, visit here and here.
- The option controls column justification, padding and maximum number of splits. A general syntax of options is
([rlc][0-9]*)*(f[0-9]*)?
. - The numbers after
r
,c
orl
determine how many spaces will be added after columns and the number afterf
controls how many matches will be made based<regex>
. - For example,
c2r3f1
means- first column is centered followed by 2 spaces
- second column is right-flushed followed by 3 spaces
- only the first match is used
- If the number after
[rlc]
is omitted, 1 space will be added after each column. - If the number after
f
is omitted, only the first match will be used. - The entire option could be omitted (i.e., input only the regular expression). In that case, default option,
l1f0
will be used. It means:- All columns are left-justified.
- A space is added after each column.
- All matched delimiters are aligned.
More about regex and options
- Use non-capturing parenthese
(?:regex)
instread of capturing parenthese. - 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).
- For example,
- 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.
- For example,
- The symbol
*
repeats the preceeding justification flags.- For example
r*3
equalsrrr
, and(cr3)*2
equalscr3cr3
.
- For example
- (Experimental) Besides
r
,c
andl
, there is a newu
flag which stands for “unjustified”.
Live Preview Mode
Table Mode
Hit ESC or use the command AlignTab: Exit Table Mode
to exit table mode.
Installation
Examples
Some simple examples. You can also contribute your examples there.
Keybinds
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" }
]
}
Named patterns
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.
Custom Context Menu
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" : "\\{"}
}
]
}
]
CJK Support
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.
License
AlignTab is licensed under the MIT License.