VimPlugin: vim-gnupg: Difference between revisions

From wikinotes
Line 44: Line 44:
let g:GPGPreferArmor = 1
let g:GPGPreferArmor = 1


" existing secrets will attempt decryption using these allowlisted keys
" Optionally, allowlist keys for decryption
" (otherwise tries all)
" (otherwise tries all)
let g:GPGDefaultRecipients = ['foo@domain.com', 'bar@domain.com']
let g:GPGDefaultRecipients = ['foo@domain.com', 'bar@domain.com']

Revision as of 02:09, 29 May 2022

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, allowlist keys for decryption
" (otherwise tries all)
let g:GPGDefaultRecipients = ['foo@domain.com', 'bar@domain.com']

Debugging

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