Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple alignments with single keybinding #39

Open
georgecrawford opened this issue Nov 5, 2014 · 6 comments
Open

Multiple alignments with single keybinding #39

georgecrawford opened this issue Nov 5, 2014 · 6 comments

Comments

@georgecrawford
Copy link

georgecrawford commented Nov 5, 2014

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.

@randy3k
Copy link
Owner

randy3k commented Nov 5, 2014

it is tough..it may not be possible to do it with one single regexp.

@lifehackett
Copy link

👍 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.

@randy3k
Copy link
Owner

randy3k commented Jan 27, 2015

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.

@KroniK907
Copy link
Contributor

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.

@randy3k
Copy link
Owner

randy3k commented Jan 22, 2016

@KroniK907 thanks for the input.

@KroniK907
Copy link
Contributor

Updated pull request #59
Added the match_all argument that was mentioned above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants