Closed yuhan0 closed 5 years ago
This functionality is already available under the grp
keybinding. For skipping/undoing backwards use grp
, for skipping forward use grn
or C-t
.
That's only the case for cursors created by matching (where evil-multiedit or iedit tends to be a better option).
For line-based cursors created by "grj"/"grk" (which is 99% of what I use evil-mc
for), or even arbitrary positions with "grh", I believe this functionality does not currently exist.
quick demo:
I see. I'd prefer to fix grp
to work with cursors created by grj
rather than create yet another shortcut. Also , also the tests must pass before I can consider merging a pull request. By, the way you can use a number with grj
/grk
to create exactly the number of cursors you want. But, I agree that it would be nice to have the ability to undo individual cursors regardless on how they were created.
To run the tests locally do in the evil-mc
directory:
make test-install
make test
Thanks, I'll look into running the tests :)
With respect to "fixing" grp
to handle this case - I personally feel that overloading skip-and-goto-prev-match
to fit the user's intention of "undo that last mistaken cursor" isn't a very good idea and would hurt discoverability.
Besides, "undo last cursor" is a primitive action in other editors like Sublime Text and VS Code with native multiple-cursor support, I think it's reasonable to expect similar functionality under a top level shortcut.
The test failure appears to be due to the "gru" keybinding for evil-mc-undo-all-cursors
being changed.
I'm not quite familiar with the testing framework being used here, but it seems that replacing "gru" in features/evil-mc-copy-paste.feature
with my proposed replacement "grq" makes the current tests pass.
I went ahead and pushed that change in order for the tests to pass - open to discussion about the default bindings of course :)
Thanks @yuhan0 looks good. One last thing, could you also update README.org
to reflect the new keybindings.
Okay, just got around to it :) By the way would you prefer having "grU" as the replacement binding for undo-all-cursors? In my mental model I think of it as "quitting" multiple cursor mode, but the command name suggests it as a "stronger" version of undoing cursors.
Also pushed a small correction - some
-> cl-some
from the cl-lib library
I like grU
but grq
is easier to type and since this is a pretty common operation I think we can leave it as is.
Merged! Thanks @yuhan0
This PR adds functionality of undoing the last added cursor, which is available in other editors' multiple cursor implementations. This makes it possible to correct the common mistake of creating too many cursors (e.g when hitting
C-n
past the intended range), without having to start all over again.Also changes the binding of "gru" to undo the very last added cursor instead of deleting all cursors, in line with the meaning of "u = undo last action" in evil mode.
The previous binding of
evil-mc-undo-all-cursors
is moved to "grq" ("quit")