-
Notifications
You must be signed in to change notification settings - Fork 4
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
More documentation on defining your own rules #6
Comments
Ok, here's what I have so far. Let me know if you have suggestions to improve this to allow for more of the use cases above: \ {
\ 'mode': 'n',
\ 'delimiter': ['\/'],
\ 'surrounds': ['''\|"\|\s', '''\|"\|\s']
\ } |
(By the way, I did finally find those other property keys in the docs . . . although I still didn't understand them.) |
Thank you for your comment! Indeed, names for default rules sounds a good idea. Though regular expression is an extremely useful tool, it's readability is awful. I will work for it and better documentations in this weekend. In short
If the cursor is on "arg1", what I want to do is to exchange the order of three items, "arg1", "[arg2a, arg2b]" and "arg3". However, the rule
would change the order of four items, "arg1", "[arg2a", "arg2b]", and "arg3". The second list argument is split into two parts because it includes a delimiter inside. Thus what I need is:
Then the grouping by "[]" is considered and a comma inside "[arg2a, arg2b]" is ignored to re-order "arg1", "[arg2a, arg2b]" and "arg3". Without
|
The immutable is something neither a delimiter nor an re-ordered item. But... Actually it is almost same as a delimiter, and not necessarily to use at this moment, probably... Only the difference is re-ordering text would not be placed between a delimiter and a immutable. For example, regarding "," as delimiter and ";" as immutable.
Given that I want to change the locaion of "text1" in the following string:
This could be |
Ok, I understand braket. Still not so much quotes and literal_quotes. Your explanation also made me wonder how this plugin would handle es6 default function parameters and destructuring assignments, like:
and
But these are sort of side questions. In general, I was really excited about this plugin. I had a swap parameters plugin previously, but it wasn't always super accurate, and it did really weird things if you ever triggered it outside of a parameter list. This is more general purpose and extensible, which I like. It's just hard to get started because vim regular expressions can be really tricky. |
Is |
The Help? Again, for reference, here's the rule definition I'm using:
|
It seems to have something with the dollar sign in the second string because it works fine if I take that out. |
The It seems the filepath (url?) is a difficult example. So far I use this to do.
However, I still don't understand what happened in your screen shot. Do you have any other rules in |
I don't. I didn't assign the default ones even. Your gif looks like it's working as I'd expect, so let me try that and see if it works on my system too. |
Hmm, copied yours exactly, and still seeing the same behavior. Maybe we have a difference in settings that would cause this? |
Hmm, could you tell me the version of your vim editor? You can check by |
|
Thank you! Let me think. |
Just to be clear, I think this probably means it's not really on you to figure this out, although I do appreciate the help. |
Thank you for your kind words. It's just for my curiosity, never mind. |
It's not so reliable and problemsome, even worse that it is very time consuming.
Add 'description' key. It does nothing but helpful when user check it for reference.
Hi, I'm still revising the documents, and it has not finished yet, but maybe I understand the problem. It seems that the existence of the Probably the syntax settings for javascript (?) were different with my and your vim. Now it should work as we expected. I will continue to update documents! |
Oh cool! I'll give it a try. Thanks! |
Yeah, it's working now. |
Hi, finally I updated the documents. I hope it would be better than previous! |
Thanks! Looks good! |
I'm looking at the help doc and the default rules but still struggling to understand how to write my own rules. Not all of the possible keys are defined in the docs, which makes it a challenge. Some make sense and some I can guess at, but what are
braket
,quotes
,literal_quotes
, andimmutable
for?For reference, I'm trying to add a rule to swap parts of url path (e.g.
foo/bar
->bar/foo
. So I've got the delimiter as['\/']
but I don't know how to tell where the beginning and end are, as a url may or may not start/end with a slash . . . or with quotes. I.e. I'd like it to work for urls that look likeBut also for things like
and
GET /foo/bar/baz # urls might not have quotes in a conf file
and maybe even more complicated things like
although that last one seems like it would be difficult to match and swap properly.
Also, it would help me understand the default rules if they had names or examples or both. I can't tell easily just from looking at them what they would match, which means I don't actually know what all the default rules are (which is important if I don't want to end up accidentally reinventing the wheel and if I just want to know what works out of the box . . . like, where can I use this thing I just installed?) In general, a list of default rules with examples in main README (and maybe in the helpdocs too) would be helpful.
The text was updated successfully, but these errors were encountered: