Last Updated: February 25, 2016
·
1.505K
· jasonseney

Encrypt and Save a File with GPG and Vim

From within vim:

:w !gpg -c -o myfile.txt.gpg

Or add a command to your .vimrc:

command -nargs=1 WriteEncrypted w !gpg -c -o <q-args>

So you can then simply type:

WriteEncrypted myfile.txt.gpg

Detailed explanation of parameters here:

http://jasonseney.com/post/18646147210/open-edit-save-encrypted-files-with-vim-and-gpg