Last Updated: February 25, 2016
· jasonseney

Decrypt and Open Encrypted File into Vim

In your shell config:

vimdecrypt() { gpg -d "$1" | vim - -n -i "NONE" "+set filetype=$2"; }

Now you can type:

vimdecrypt my_secure_file.txt.gpg

Note: This will NOT decrypt into a file, will NOT open a swap file, and NOT write to .viminfo. There will be no trace of the file other than what's in vim's memory space.

Explanation of parameters are here: