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

feature request: Improve c0/d0 Motion for Renaming Files Instead of Deleting #570

Open
1 task done
metaboulie opened this issue Jan 27, 2025 · 1 comment
Open
1 task done
Labels
enhancement New feature or request

Comments

@metaboulie
Copy link

Did you check existing requests?

  • I have searched the existing issues

Describe the feature

Issue Description

The current behavior of the c0/d0 motion in oil.nvim deletes a file entirely and creates a new one, which is unintuitive for renaming workflows.

Proposal

Make the c0/d0 motion support renaming a file instead of deleting and recreating it.

Expected Behavior

When c0 is used within the filename:

  • Transition into renaming mode (similar to a buffer edit) without deleting the file.
  • The file should only be renamed after the change is applied.
Screen.Recording.mov

Provide background

When renaming a file (e.g., foo.md), users often move the cursor to the file name, perhaps around the . delimiter, and use motions like c0 to change the file's name. Currently, this deletes the file instead of facilitating a rename. Changing this behavior to directly rename the file would:

  1. Align with user expectations for text-editing motions in buffers.
  2. Provide a smoother, less destructive workflow for managing files in the explorer.

What is the significance of this feature?

strongly desired

Additional details

No response

@metaboulie metaboulie added the enhancement New feature or request label Jan 27, 2025
@stevearc
Copy link
Owner

This is unfortunately one of the limitations of the implementation right now. I don't particularly want to introduce some sort of hack like remapping c0/d0 because I think that's more likely to create confusion be difficult to support. The solution here is if Neovim adds support for extmarks that can be deleted and pasted. We have 2/3 of what we need with the invalidate and undo_restore parameters of nvim_buf_set_extmark, but we need some way to make it so that a deleted range with an extmark that gets pasted retains that extmark (or some data from the original). If we get that, then I can get rid of the leading ID numbers on the lines entirely and fix this edge case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants