randy3k / AlignTab

An alignment plugin for Sublime Text using regular expression
MIT License
631 stars 25 forks source link

[Feature Request] Allow a user to provide multiple regex to run sequentially #58

Closed KroniK907 closed 8 years ago

KroniK907 commented 8 years ago

I will often have some lines which I would like to run two or three AlignTab commands on.

one example would be a set of ternary operators like this:

$variable = empty($var) ? $var2 : $var1;
$var3 = empty($var) ? $var5 : $var4;

In this case I need to run AlignTab 3 times. Once to align on the =, once to align the ? and once to align the :

Sadly this means either I have to have 3 key binds set up, or 3 custom context menus, or run each regex manually. It would be nice if I could run the align_tab command once with a list of regex that get executed sequentially.

I'd create a pull request but i'm pretty busy at the moment. Thanks!

randy3k commented 8 years ago

If each line only contains one =, ?, and :, you could use the regexp =|\?|:.

And in fact, this has been requested in #39 .

KroniK907 commented 8 years ago

Just created a pull request #59 that allows user_input to be called as list of regexp as well as a string, then iterate through each regexp in the list. Not sure if this is how you would want it done, but it works

randy3k commented 8 years ago

Thanks, it sounds great. I will review it tomorrow and merge it if there are not major issues.

KroniK907 commented 8 years ago

Further Discussion will happen on the pull request. #59