Skip to content

Single-argument swap #3087

@nriley

Description

@nriley

We'd like to support single-argument swap which expects argument to evaluate to two targets and then swaps them. That would enable commands like "swap every two tokens air" to swap air with its next token. One side benefit is that "swap air and bat" would be a synonym for "swap air with bat", which might be useful

Could probably generalize to any even number of targets. I think best behavior would be to zip first half of list with second half so that "swap <target1> and <target2>" matches "swap <target1> with <target2>" eg "swap every key air and bat". Though maybe having them behave differently would be useful?

⬆️ @pokey edit ⬆️


⬇️ @nriley original ⬇️
I'd like to be able to "swap" two instances of a scope, like this:
Image

As @pokey mentioned (and I've accidentally said), this also would make the idiomatic "swap a and b" (versus "swap a with b") work fine.

For 2 targets, "reverse" already appears to do the right thing if spoken instead of "swap".

If we wanted to generalize this further to do pairwise swaps, it'd no longer be the same as reverse. I can't honestly think of a use case though!

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions