A few months ago I read Drew Neil's article about split windows and the project drawer. It's a great article and I strongly recommend you to go ahead and read it.
The article got me spending some time with netrw and sure enough, it replaced NERDTree. One thing that annoyed me though, was its default for deleting directories. Quoting from :help netrw-delete
.
Deleting/removing files and directories involves moving the cursor to the file/directory to be deleted and pressing "D". Directories must be empty first before they can be successfully removed.
This is not a default I'm happy with, but as with everything else in Vim, netrw is customisable. The default command for deleting local directories is rmdir
which requires the directory to be empty. By setting g:netrw_localrmdir
to something else, such as rm -r
I get the behavior I want.
Excerpt from my .vimrc:
" Allow netrw to remove non-empty local directories
"
let g:netrw_localrmdir='rm -r'
Happy Hacking!
GitHub: KevinSjoberg | Twitter: KevinSjoberg
I was trying to achieve the same on Microsoft Windows 10 with following line:
The switch
\s
is similar to-r
.However, there were issues in the code of netrw-156 in vim8 which require to switch to the more recent netrw-162g version available on http://www.drchip.org/astronaut/vim/index.html#NETRW.
With this new version the variable becomes obsolete:
This means your tip does not work anymore.
That's too bad. I was hoping that netrw would offer more convenient default behavior than the command-line. However, there is also the risk that a simple press of
D
deletes your complete homedirectory. So there is a good reason not to offer such a feature.The following might be a better reason to re-introduce this variable:
When people want to use programs like
rmtrash
(OSX) ortrash-cli
(https://github.com/andreafrancia/trash-cli/), they cannot do this anymore.