Closed NoahTheDuke closed 6 years ago
Thanks! I think it might be better if it's done as a pre-check here: format.vim#L97
The pattern could be something like:
[[^\[\]]*:[^\[\]]*\]
but it might need an extra bit for the slice stepping:
[[^\[\]]*:[^\[\]]*\%(:[^\[\]]*\)\?\]
I haven't test it, but I think those would match [:]
, [x:]
, [:x]
, etc.
In reply to:
This removes all surrounding whitespace from the the operators +, -, *, /. Originally, PEP 8 dictated leaving space around arithmetic operators, but that has changed. Post-2012 PEP 8's Other Recommendations says to use spaces when determining priority level (even though I find that unclean), but as it's left up to user discretion, I'd suggest making the default remove extra whitespaces around operators instead:
Yeah, the cleanups are meant for things under PEP8's Pet Peeves, which I consider to be a matter of opinion/taste. The original intention was for cleaning up inherited code that was written by someone trying to impose a different language's coding style (java devs, mostly). My reasoned opinion for wanting to remove whitespace around slice operators has more to do with readability.
If you're quickly scanning through the code to look for something, you might not see the immediate difference between these two lines:
x = [1 + 2, 3 + 4]
x = x[1 + 2 : 3 + 4]
but, it's slightly easier to spot like this:
x = [1 + 2, 3 + 4]
x = x[1+2:3+4]
It also helps that you can use the W
motion to select the entire slice expression. If preserving some of the whitespace is wanted, we should probably make it so that they're properly balanced as described in PEP8.
The parts under Other Recommendations
are okay, but I'm not willing to tackle parsing out the expressions.
@NoahTheDuke Is this abandoned?
Yeah, sorry. I don't remember why cuz I def tried to handle some of your comments, but that was two computers ago.
Decided to do the "hard" work myself! Quick fix for the issue I had in #35.