K Pradeep Kumar Reddy
K Pradeep Kumar Reddy

Reputation: 650

not able to recover vim encrypted file after :set key=

Encrypted a file in vim using :X. I opened the file and entered a wrong key, it showed garbage. Then I tried to turn off encryption by executing the following in command mode :set key=. Now i'm not able to decrypt the file.

I have encrypted my file so that nobody reads it. If someone try to access the file with wrong key and then execute :set key=, then how to get back my original file?

Upvotes: 0

Views: 388

Answers (1)

Ingo Karkat
Ingo Karkat

Reputation: 172698

A way to re-try encryption key entry after a wrong attempt is via unloading and re-editing the file:

:bdelete | edit #

If you have written the (garbled) buffer after :set key=, the contents may have been lost, as you have persisted (now unencrypted) the garbage. You can check by attempting a re-edit or looking at the file contents; it should start with VimCrypt~.

Upvotes: 1

Related Questions