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: move directories while updating buffer paths (supercharged :move) #12923

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

satoqz
Copy link
Contributor

@satoqz satoqz commented Feb 20, 2025

:move is nice, but it doesn't let you move a directory and automatically update the buffer paths for any files inside of it that are opened in the editor. Currently this is rather cumbersome, you need to :sh mv foo bar, close all affected buffers, then reopen them again at their new paths.

This PR proposes a couple of changes:

  1. Editor::move_path now handles updating the paths for all affected buffers when it moves a directory.
  2. :move takes 1 to n arguments. If a single argument is given, the argument is the destination path and the buffer path is the source (this is the existing behavior, which continues to work as before). If multiple arguments are given, :move behaves like the Unix mv command: :move foo bar moves foo to bar, :move foo bar baz moves foo and bar into baz.
  3. :move foo bar knows to move foo to bar/foo if bar is an existing directory. Again this mirrors the behavior of Unix mv and should be more intuitive.

I think this is a natural extension to the existing behavior and has worked very well for me during testing so far. Any suggestions or feedback is appreciated :)

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

Successfully merging this pull request may close these issues.

1 participant