Is it possible to configure VIM so that when an attempt is made to edit a file encrypted by VIM, or to encrypt a file, VIM would warn or refuse such action?

1 Answer 1


I think you should build your custom version of Vim excluding this feature (FEAT_CRYPT) completely. This is the most complete and error-prone solution.

To make Vim fail on attempt to write encrypted data you can try something along those lines

augroup example | au!
    autocmd BufWritePre * if !empty(&key) | throw "No encryption allowed here!" | endif
augroup end

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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