• Stars
    star
    626
  • Rank 71,755 (Top 2 %)
  • Language
    Python
  • License
    MIT License
  • Created almost 12 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An alignment plugin for Sublime Text using regular expression

AlignTab

test codecov

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 Palette C+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 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>.
  • 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).
  • 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 example r*3 equals rrr, and (cr3)*2 equals cr3cr3.
  • (Experimental) Besides r, c and l, there is a new u 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

Package Control

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.

More Repositories

1

radian

A 21 century R console
Python
1,976
star
2

Terminus

Bring a real terminal to Sublime Text
Python
1,382
star
3

ProjectManager

Project Manager for Sublime Text
Python
323
star
4

SendCode

Send code and text to macOS and Linux Terminals, iTerm, ConEmu, Cmder, Tmux, Terminus; R (RStudio), Julia, IPython.
Python
204
star
5

R-Box

R package for Sublime Text 3
Python
172
star
6

collections

High-performance container datatypes for R
R
102
star
7

remote-atom

rmate for atom
CoffeeScript
85
star
8

LaTeXYZ

Better LaTeX experience with Sublime Text
Python
74
star
9

AutoWrap

Auto (Hard) Wrap for Sublime Text 2/3
Python
63
star
10

arrangements

Fast Generators and Iterators of Permutations, Combinations and Partitions
R
52
star
11

rchitect

Interoperate R with Python
Python
51
star
12

LaTeXBox

A lightweight but deprecated LaTeX Plugin for Sublime Text 3
Python
46
star
13

Whitespace

Remove Trailing Whitespace for Sublime Text
Python
41
star
14

AutomaticPackageReloader

Automatically reload submodules while developing a Sublime Text package.
Python
37
star
15

shiny-cloudrun-demo

Running Shiny app on Google Cloud Run
R
34
star
16

UnitTesting-example

A getting started example for UnitTesting
Python
32
star
17

dotfiles

some of my dotfiles
Python
30
star
18

ChangeList

DEPRECATED: The missing Change List for Sublime Text 2/3 - History List, Last Edit ...
Python
30
star
19

SyntaxManager

Applying settings to a given syntax/extension
Python
29
star
20

homebrew-r

Homebrew formulas for R and related tools
Ruby
25
star
21

UnicodeCompletion

Insert Unicode LaTeX δ and Emoji 🍻 to Sublime Text
Python
24
star
22

LaTeXTab

Excel/CSV to LaTeX Table
Python
18
star
23

SendTextPlus

SendTextPlus is deprecated in favour of https://github.com/randy3k/SendCode
Python
17
star
24

otp

One Time Password Generation and Verification
R
16
star
25

retry

Repeated Evaluation
R
15
star
26

rpy2

Deprecated: use the official mirror: https://github.com/rpy2/rpy2
Python
15
star
27

xptr

Manipulating External Pointer
R
13
star
28

GitStatusBar

A more compact Git StatusBar
Python
13
star
29

rango

Calling R from Go and a better cli for the R console (WIP, nothing is working now)
Go
12
star
30

osascript

some useful apple scripts
AppleScript
9
star
31

iterpc

iterpc: deprecated in favour of https://github.com/randy3k/arrangements
R
9
star
32

sublime-default

Sublime Text 3 Default Package - This rpeo is outdated, check https://github.com/twolfson/sublime-files
Python
9
star
33

OpenHere

Open Finder, Terminal and iTerm in Sublime Text
AppleScript
5
star
34

GitHubChecks

Show GitHub checks result in Sublime Text
Python
5
star
35

sess

R
3
star
36

closure

Tools to create and manipulate closures
R
3
star
37

LSP-julia

Julia config for Sublime Text LSP
Python
3
star
38

netlify-deploystatus

JavaScript
3
star
39

random-scripts

some random scripts
Python
2
star
40

R-Extended

Improved R syntax files for Sublime Text
JavaScript
2
star
41

Keypress

Simulate Keypress in Sublime Text
Python
2
star
42

shiny-appengine-demo

Running Shiny app on Google App Engine
R
1
star
43

lineedit

lineedit: a readline library based on prompt_toolkit which supports multiple modes
Python
1
star
44

gh-actions

Shell
1
star
45

juliatalk

Jupyter Notebook
1
star
46

workbench

Bootstrapping my workbench on unix machines
Shell
1
star
47

randylai.info

source of randylai.info
HTML
1
star
48

UnitTesting-docker

Go to https://github.com/SublimeText/UnitTesting/tree/master/docker
Shell
1
star
49

ustring

Tools For Unicode Strings
R
1
star
50

RSpace

A Cocoa GUI for R on OSX
Objective-C
1
star
51

submit

A webapp for submitting project
HTML
1
star