oil.nvim
oil.nvim copied to clipboard
feature request: Allow moving file into a new directory when the name contains a slash
Did you check existing requests?
- [X] I have searched the existing issues
Describe the feature
I have a file like:
foobar.js
if I rename the file to
hello/foobar.js
I'd like to create a directory hello
and put foobar.js
in it
Provide background
No response
Additional details
If it's a feature you may like, ~i can write a PR~
This is a neat idea, but it's more complicated than it first seems. The main issue is the possibility that hello/foobar.js
or even just hello/
already exist. It's doable, but I'll have to be real careful about the edge cases.
I'll keep this on the back burner until I get the time to look deeper into it.
+1 for this one!
I've been using oil.nvim
for quite a while already and absolutely love it! I think this feature will kind of complete all the flow that typically happens when editing/creating files/folders.
Another fun complication :) -- move file to parent directory by renaming it ../file.txt
or ./../file.txt
. For some reason this (as well as subdirectories) feels very intuitive for me in the context of the rest of oil.nvim's features.
Another fun complication :) -- move file to parent directory by renaming it
../file.txt
or./../file.txt
. For some reason this (as well as subdirectories) feels very intuitive for me in the context of the rest of oil.nvim's features.
Absolutely! Or moving it into a directory inside a parent one by ../dir/file.txt
another one (for fun): transforming a file to a folder if the file is empty and without extension. Use case: I create a foobar file: hoo noo, i wanted to create a folder but I created an extensionless file instead, rename to foobar/
if the file is empty and without extension
I think that doesn't really necessary. Directories with dots are perfectly valid. Alternatively, if a file is not empty and you are transforming it into a directory, then this information can easily be shown in the confirmation window.
But I would go with any way @stevearc decides to implement, if he does.
@titouancreach congratulations, your pain is also my pain! And that's a much easier fix, so I've gone ahead and implemented it. Now you can change a file to a dir or vice-versa by adding/removing the trailing /
. It'll translate that change to a delete + create.
For the other requests in this issue, I'm still looking into it. I have some ideas and a rough plan now, but I just haven't had the unbroken time to sit down and hash it out.
Great job @stevearc ! I update my packages right now !
Just discovered Oil and love it so far, but this is definitely one of the things I'm hoping gets added. Currently my solution is to continue using telescope file browser to handle moving files between directories, but I'd definitely LOVE to be able to do that in Oil :)
Hey pal! Love the plugin a ton. Totally heard on the complexities involved in this feature request, too. I'm here because I also just attempted to do this intuitive feeling ask, and the operation of course failed.
Let me know if there's anything I can do to help you with this feature. Thanks for an amazing project!
Loving this plugin and I'm feeling the same way as those above. Would be a great addition to this awesome package.
Hello, sorry but I have not understood the whole discussion, I would like to kindly ask if it currently possible to automatically create missing folders during file operation.
If still not possible, I agree this would be a must-have feature (if feasible).
Made a PR which I think works for all the cases I can think of. Let me know if I missed anything!
This is working great for me! Thank you!
moving files into the parent directory using ../file_name.txt
still doesn't work, are there any plans for implementing this? I really enjoy oil but being able to move things to the parent directory is quite important to me when I am refactoring things. For now I am gonna have to use @pi314ever fork as that feature works there.
Hi, moving a file to an existed folder doesn't work for me, either. Just as below, I want to move auto-session.lua
to archive/auto-session.lua
, but it prompted that Filename cannot contain path separator
. if I rewrite the whole line to archive/auto-session.lua
regardless of the icon at the beginning then it will just create a blank new file istead of moving file.
I really like oil and reply on it heavily. Please correct me if I've got it wrong. If the feature does miss for the moment, hope that we could consider to add it in the near future. Thank you in advance.
Hi, moving a file to an existed folder doesn't work for me, either. Just as below, I want to move
auto-session.lua
toarchive/auto-session.lua
, but it prompted thatFilename cannot contain path separator
. if I rewrite the whole line toarchive/auto-session.lua
regardless of the icon at the beginning then it will just create a blank new file istead of moving file. I really like oil and reply on it heavily. Please correct me if I've got it wrong. If the feature does miss for the moment, hope that we could consider to add it in the near future. Thank you in advance.
Yep, same thing still happening
For anyone still having this issue, my suggestion is to simply delete the file you want to move with dd
(do not save the deletion), then move into the folder you want to move the file into, paste the deleted file and then Save. It will prompt you to move the file.
This is a neat idea, but it's more complicated than it first seems. The main issue is the possibility that
hello/foobar.js
or even justhello/
already exist. It's doable, but I'll have to be real careful about the edge cases.
I think it might be useful to cover the most simple and unambiguous case first: if the folder does not exists and there are no duplicated files when trying to move, then it can be created and al the files moved at once. It seems "future-proof" enough, so more complex edge cases might be treated in the future. In my case, this would be enough most of the times.
I think it might be useful to cover the most simple and unambiguous case first: if the folder does not exists and there are no duplicated files when trying to move, then it can be created and al the files moved at once. It seems "future-proof" enough, so more complex edge cases might be treated in the future. In my case, this would be enough most of the times.
I agree. That would greatly improve its usability.