How to edit a .gpg file with vi?

Original Answer

The gnupg plugin for Vim does this:

This script implements transparent editing of gpg encrypted files. The filename must have a ".gpg", ".pgp" or ".asc" suffix. When opening such a file the content is decrypted, when opening a new file the script will ask for the recipients of the encrypted file. The file content will be encrypted to all recipients before it is written. The script turns off viminfo and swapfile to increase security.

EDIT #1

As of 2016-07-02, the original gnupg plugin is now no longer being maintained:

Due to the lack of time I'm not able to continue the development of this script. James McCoy took over development. New versions can be found at vimscript #3645.

There is however a new version:

  • gnupg.vim - Plugin for transparent editing of gpg encrypted files. : vim online