Working with encrypted files can be troublesome at times. Thanks to James McCoy, there is a plugin for vim that makes the task so much easier.
Vim supports encryption with the -x switch. At time of writing, blowfish2 symmetric encryption is only encryption available. That means a password needs to be set for every file. I use gpg to encrypt files with asymmetric keys. With the vim-gnupg plugin, I can seamlessly edit encrypted files. Here is how.
Download the plugin from https://www.vim.org/scripts/script.php?script_id=3645. Unzip the file in ~/.vim/pack/vendor/start
wget -O /tmp/vim-gnupg.zip https://www.vim.org/scripts/download_script.php?src_id=27359 unzip -d ~/.vim/pack/vendor/start/ /tmp/vim-gnupg.zip rm -f /tmp/vim-gnupg.zip
The plugin will be started by vim automatically. To edit an encrypted file, make sure it has an extension of .gpg, .pgp, or .asc. You will be asked to unlock your gpg key if it’s not already loaded in gpg-agent. Then you will be able to edit the file directly. When it’s saved, it will be re-encrypted.
I think that’s awesome.