VimPlugin: vim-gnupg

From wikinotes

Open/encrypt gpg encrypted files directly from vim.
Good for lab notes, journals, etc.

You may also be interested in git-crypt as an alternative.

Documentation

github https://github.com/jamessan/vim-gnupg
:h gnupg https://github.com/jamessan/vim-gnupg/blob/main/doc/gnupg.txt

Usage

The recipient determines the key that will be used to encrypt the file.

Open already encrypted files

echo foo | gpg --encrypt --armor -r yourkey  # ex. yourkey='you' from 'you@example.com' > foo.gpg
nvim foo.gpg  # the key will be detected and used if present

New files, from commandline

touch foo.gpg
nvim foo.gpg
# a split will appear. add email key to use (gpg --list-keys)

New files, from vim

:e new.gpg
:GPGEditRecipients  " add email of key to use (gpg --list-keys)
:w

Configuration

let g:GPGPreferArmor = 1

" Optionally, if no recipient (gpgkey) is set, default to encrypting/decrypting with these keys
" (encrypted keys will generally know which key to use, but new encrypted files may not)
let g:GPGDefaultRecipients = ['foo@domain.com', 'bar@domain.com']

Debugging

" log verbose
:set verbosefile=debug.log
:3verbose write foo.gpg