Got a great tip from usevim about Vim’s built-in file encryption, which includes two cryptmethod methods: cm=zip (PkZip compatible, default method) and cm=blowfish. It should be hard to guess which encryption method that you should be using if you want to have a safer method, that is “blowfish.”

I made a video for demonstrating, click to watch on YouTube:

https://i1.ytimg.com/vi/GWBie56pb88/sddefault.jpg

For single files, you can just type in :X and Enter to initialize the method, Vim will ask you for the key. Once you input the key, save the file, which will be encrypted with the key you just entered.

If you have to work with multiple encrypted files at the same time, you may want to consider to set key to your encryption key. But as Chrome/Chromium’s warned us: someone may stand behind you. Besides, it’s not recommended to do so by the Vim help, you can load the key somewhere without echoing out to screen.

When key has value, not empty, Vim will use it to encrypt and decrypt files, whatever you want to save or open. So you won’t need to type :X, just do as you usually do.

However, since you have many files, it might be a better idea to use things like EncFS, it would make your life easier. It doesn’t require special permission, but your system has to have FUSE for EncFS to mount the encrypted directory.

1   Further reading

  • :help cryptmethod, :help :X, and :help key.