I love using Vim yet have a lot of very sensitive, encrypted files to edit, sometimes on an unencrypted drive, and can't have any residual information from these files forensically accessible to other users of that hardware or others. I realize I can just do :set viminfo= but this disables lots of the best features. How can I get Vim to encrypt the .viminfo file instead so that no information is stored on the drive?

1 Answer 1


Do you mean swap files?

.viminfo is stored in your home directory, even when you're editing files on external disks.

Swap files default to being stored in the same directory as the file you're editing though.

You can use settings viminfofile and directory to set where the .viminfo and swap files (respectively) are stored, so that they are stored within an encrypted drive/partition.

I use this:

set directory=$HOME/tmp/vim/swap//

because it speeds up working on slow remote-mounted disks such as sshfs.

You could do that plus something like (untested)...

set viminfofile=$home/tmp/vim/info

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.