-
Notifications
You must be signed in to change notification settings - Fork 90
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
Split comma-separated parameters #68
Comments
First off, it would be nice to know which language this is :). I'm guessing it's coffeescript, based on the triple quotes. As for the lists -- the only way that list splitting would work is if there are delimiters. There has to be some way to detect "you're in a list", and checking for commas is by far not enough. If it was The implementation depends on the language, though. Coffeescript, for example, doesn't require commas on every line if it's a multiline list. I'm not sure about argument lists in function calls. |
Sorry about that, yes thats coffeescript. I was converting some old code. I know it's hard to fix everything with just regexps. Are you saying that it would work if I start on the square bracket instead? Didn't even think about that. Here's how I go about splitting long lines:
first I just extract it on a new line using
If that's not enough I split the long list:
|
I don't mean that if you try on the square brackets, it would work. I mean that, in order to implement this, I'd need to have some way to detect that these comma-delimited items are in a list. In the situation of "lists with strings that are valid hex codes", this is easy enough to do -- just split by commas. But if I just split by commas, this would do very wrong things when the strings contain commas, or when you have nested lists or function calls. If you're mainly refactoring these kinds of strings, a simple Now, if you would like me to implement generic argument/list splitting for coffeescript, I could give it a try. I guess it would work similarly to the ruby one or the python one. I would also have to consider how this would work in combination with object literal splitting. But bear in mind, this means that splitting would work like this: foo = ["one", "two", "three"]
foo = [
"one"
"two"
"three"
] So if you split it like this beforehand: foo = [
"one", "two", "three"
] I'd rather not try to detect this case, since I'd have to search back and forth for whether there are brackets or not. And I would only do this if this "looks like a list", which I'm not sure how to detect either (what if it's What do you think? Should I work on list/argument splitting or does that not help with your use case? |
Hey, thanks for getting back to me on this. Recently the pressure increased so I am accepting things as they are. I break out of brackets using vim-surroung To wrap it up, yes it would be great to have this ability, but I understand vim is not very friendly in that regard and it will cause more support headaches down the line. I don't see anybody else commenting, maybe this is a pattern nobody else is using. On a side note, yesterday
Thanks. |
I should have probably responded a lot earlier, sorry about that. To start off, thanks for your kind words regarding As for the feature itself, I did have a complaint from someone else as well that it would be nice if a list of items could be split "partially", and I admit I've had similar use cases. I'll leave this issue open for now and maybe I'll come around to implementing this yet. |
Hey, just wanted to check up if you have any new thoughts about the matter.
And now if only I could do
No need to worry about joining the lines, maybe remove the trailing comma, but it's not important. Please consider. Thanks. |
Here is what I came up with.
|
Hi, me again...
Sorry, I forgot what is the consensus on splitting lists? Is this a valid issue?
Given:
gS
Expected:
Actual:
The text was updated successfully, but these errors were encountered: