2

I just accidentally deleted an important file in :Ex (I thought I was still typing a search string and hit Shift+D and then Enter immediately).

Can I unmap this entirely to avoid this (stupid and not very likely, but still annoying) risk in the future?

3

You will need to unmap D only for the filetype netrw to do that you can create the file ~/.vim/after/ftplugin/netrw.vim and inside put the following lines:

" Avoid unwanted file deletions with D
unmap <buffer> D

Then you should be good to go, D will not do the suppression anymore.

How does it work?

See :h ftplugin, the idea is to create a file which will be sourced when the filetype of a buffer is set to netrw but after the Netrw plugin did it's own configurations so that you can override them. Note that instead you can probably use an autocommand, but I think it would be pretty redundant since that would be not using the built-in Vim mechanisms.

And the <buffer> parameter to the unmap command is necessary because Netrw remaps D only in its own buffers.

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.