AlignTab
AlignTab copied to clipboard
Multiple alignments with single keybinding
Hi @randy3k. Thanks so much for this plugin.
What I'd really like is to align whichever code block my cursor is in, using the same keybinding each time. So in a JS var
statement:
var a = 'a',
long = 'long';
...would be transformed to:
var a = 'a',
long = 'long';
... but when in a JSON object context, the same keybinding would transform:
var a = {
b: 'b',
long: 'long'
}
to:
var a = {
b: 'b',
long: 'long'
}
I've seen example patterns for both, but is there a way I can run them using the same keybinding, dependent on the context?
Thanks!
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
it is tough..it may not be possible to do it with one single regexp.
:+1: for this feature. What if instead of a single regex, it looped through a dictionary of regex's? It would loop through until a match was found and the user could define the order of precedence.
this is interesting, perhaps, we can define something like the following in named_patterns
"named_patterns": {
"js" : {
"match_all": false,
"regex" : [
"regex1",
"regex2"
]
}
}
If match_all
is false, it will loop through until a match is found. If it is true, then it will loop through all regex.
Just created a pull request #59 that allows you to declare user_input as a list and it will run through each regexp in the list. It still will take a string, so no previous functionality is lost.
I didn't see this thread until @randy3k pointed it out a bit ago, so I didn't think of the "match_all" option. I'll try and add it in.
@KroniK907 thanks for the input.
Updated pull request #59
Added the match_all
argument that was mentioned above.