2

I will try to delete some non-empty folder in netrw by pressing SHIFT + d and, after press y, i got this error:

(netrw) unable to delete directory {path}

I already put this variable in my .config/nvim/init.vim file and doesn't works: let g:netrw_localrmdir='rm -r'

As I read, this variable only works with vim 7.4 and earlier.

There's a way to delete non-empty directories with netrw in vim 8+ or nvim?

My setup:

OS: MacOs Catalina
NVIM v0.4.3

EDIT

My intention is to use as few plugins as possible, but, netrw has some other bugs, so i gave up using netrw and installed NERDTree again.

0

There's a way to delete non-empty directories with netrw in vim 8+ or nvim?

You could do :!rm -rf directory

That warning means, you have files still in that directory. So if a file in that directory you want to delete is on the current buffer, you could do this.

:!rm -rf %:h

Which deletes the directory of the current file. %:h expands to the directory of the current file, and you can even press <tab> to have it expand and you can modify the path if you wanted.


Another alternative would be, use R and just move it to /tmp or something which gets deleted automatically by the system, in my case linux.

| improve this answer | |
  • But /tmp only gets deleted on a shutdown, right? Or is it cleaned periodically ? – D. Ben Knoble Aug 2 at 3:00
  • I think it's on every restart. On WSL though, it never deletes /tmp so what I do is just add a script that deletes file older than 1week so something like this: fd . /tmp --changed-before 1w -H -x rm -rf. Which gets called every time I open my shell. – chriz Aug 2 at 5:57
  • Yeah macOS doesnt seem to delete either (except maybe restarts, tbh im not sure). Clever trick! – D. Ben Knoble Aug 2 at 12:23
  • @D.BenKnoble In Mac OS you can move it to ~/.Trash instead. Then there's an option where you can delete them every 30 days. If you want it sooner, then a script is better. – chriz 2 days ago

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.