Skip to content
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

feat: add undokeepcurs option to keep the cursor position after undo #29462

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Grolaf
Copy link

@Grolaf Grolaf commented Jun 23, 2024

feat: add undokeepcurs option to keep the cursor to the position prior to the undone operation.

Problem :

By default, the cursor is set at the top of the undo block. That means that, no matter what kind of operation it was (e.g. auto-remove for import statement), your cursor will be set to the top position of the undo block after the undo operation. You may want more flexibilité on your cursor position depending on the operation).

Solution :

Use the :set undokeepcurs option. Once you've set this option, your cursor will be set to the position where you were just after the action you want to undo. This can be useful, for example, if you are using autocommands to format your import declarations.

See an example of the result below :

neovim_keepcurs.mp4

This is my first contribution to neovim, feel free to blame me if I broke something, either the integrity or philosophy.

@Grolaf Grolaf force-pushed the master branch 2 times, most recently from 4c66a28 to 27f3e53 Compare June 23, 2024 17:34
…r the undo

This can be useful, for example, if you are using autocommands to format your import declarations. By default, when you perform the undo operation, your cursor will be moved to the top of your file, in the import instructions section, which is annoying if you want to focus on the code itself.
@justinmk
Copy link
Member

There was a request(s) for this in the issue tracker. Please link to it/them, and if there were tradeoffs mentioned, explain how this addresses the tradeoffs or why it should override the tradeoffs. And review any alternatives/workarounds discussed.

Is there an existing fooopt or foooptions option where this would fit? Possibly as a new 'cpoptions' flag.

Also needs tests.

@justinmk justinmk added the needs:response waiting for reply from the author label Jun 24, 2024
@gh-liu
Copy link

gh-liu commented Jun 25, 2024

#12374 keep the cursor after using a operator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs:response waiting for reply from the author
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants
-