Turning encryption on for a fileIf you're editing a file, to encrypt it, simply enter X at the : prompt.
Be mindful of your key. If you forget it, you will not be able to retrieve the contents of your file.
Turning off encryption for a fileTurning encryption off is equally as easy. Simply set the key setting to nothing. With the command:
Wait! Before you goAs of vim 7.3, vim uses one of two encryption methods: zip and blowfish. Zip is the same encryption that PkZip uses and is somewhat weak (can be cracked). Conversely, blowfish is more contemporary and is much harder to crack. Zip, unfortunately, is the default encryption method in vim. I would strongly suggest that you use blowfish when encrypting your files. To do this is simple enough. Simply enter the command:
I put it in my .vimrc file so it's always set.