Reputation: 3
I'm working with VIM and writing some plugins for IT I use vim every day, but I have now a necessity to encrypt my files. I liked the :X encryption with blowfish2 in Vim But I need to encrypt and decrypt my files every time. How can I record or map this encryption? because I'm using the same password for every file. So I need some king of solution that I could type the password only one time and re-use.
I've tried
:norm qa
:X
:norm q
And
:w! /home/carlos/Downloads/teste.txt
:norm @a
And hundreds of silly things :D But I only got headache
Upvotes: 0
Views: 59
Reputation: 3326
You're probably coming at the problem from the wrong angle. I don't think Vim is the solution here but an encrypted filesystem you mount and unmount at will.
EncFS comes to mind, which is a FUSE-based filesystem but potentially unsafe. There's Cryptomator and dozens of others, it all depends on your OS, environment and safety requirements.
This also obviates the need to cache the password somewhere for repeated use.
Upvotes: 0
Reputation: 15186
:X
sets a value of a (buffer) local option. All you need to do is to set the option globally. That is, use set key=password
instead. Note that Vim will not save the password in the command history, so it's almost safe to use this. There are a couple of points though.
As it's a global option, it could influence some files you don't want to be encrypted. Use setlocal key=
to prevent such files from being encrypted.
The input of set
is echoed on the screen, so watch your back ;-) Also, you will not be prompted twice, so try not to make mistakes.
Do not put set key=password
in your vimrc, unless you're absolutely sure no one else can read it.
Upvotes: 1