-
Notifications
You must be signed in to change notification settings - Fork 203
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
Swap operands #313
Comments
I love this idea, I've been wanting it for a while. Not sure I'll be able to implement it for every language we support, but I'll try 😃 |
I've run into some unexpected behavior when swapping operands within chained associative operations. The ProblemTo see what I mean, consider the following expression: 1 + 2 + 3 Treesitter parses this into an AST with two
and
So there are two swaps that I can make, corresponding to the two
However, as a user, I want to imagine this expression as a list of
Proposed Solutions
@zdog234 @theHamsta, what do you make of these options? |
Hi, any news on this feature? |
sorry @HungryJoe I missed you question :/ fwiw, I do agree that 2 is the most intuitive behavior. If it'd require a major refactor for this project, it seems like this might be a good opportunity for a dedicated plugin |
Is your feature request related to a problem? Please describe.
imagine you write out something like this
But you realize that you actually want to swap these.
you've gotten okay at vim motions, so you
F-D0P
, but then realize you've still got a ways to go:Thankfully your cursor's in a convenient place, so you can easily add a minus sign in the middle:
You've still got to
0dw
to clear up the leading-
. Finally, you're in a state where your format-on-save hooks will clean things up:Describe the solution you'd like
I'd like to be able to add an
@operand
mapping to myswap
configuration, e.g.:Describe alternatives you've considered
I guess there might be a swapping-specific plugin that I could look for. If it doesn't exist, I suppose I could try to implement it, although I'd rather try to implement it in this project if it's possible (I don't know what's involved in creating a textobject for treesitter)
Additional context
nil
The text was updated successfully, but these errors were encountered: