Thursday, June 19, 2025

Encrypting text in vim with the vim-gnupg plugin


Plug 'jamessan/vim-gnupg'

" GPG SETTINGS for just password
let g:GPGPreferSymmetric = 1
" gpg so temp is also encrypted
" Prevent backup files (avoid leaving decrypted content on disk)
set nobackup
set nowritebackup
" Encrypt temporary files too
let g:GPGUseAgent = 1

Add above to vimrc and below to bashrc


# vim gpg
GPG_TTY=`tty`
export GPG_TTY

This symmetrical encryption prompts for a password on save and for 10 mins lets you re-open without a password in vim. To clear the cache so you are prompted immediately run in the terminal:


gpgconf --kill gpg-agent

No comments:

Post a Comment