I have an archive which contains encrypted text files with sensitive data. Is it safe to open them with vim/gvim?

I'm afraid vim/gvim will leave content of the files on the drive/memory even after I close them.


2 Answers 2


No. You should disable swap file and unset viminfo.
Also the memory contents is not encrypted.

More info here.


As mentioned by Antonio, it's a good idea to disable the swap file and also prevent backups:

:set noswapfile nobackup

If you want to make sure that it does not stay in memory, just quit vim once you are done. If you have multiple instances of vim running, I would imagine that all need to be closed to make sure, but on my computer, I can clearly see that each instance is a separate process so only the instance you used for this purpose needs to be closed. Note that when memory is returned to the kernel (all of which is when a process exits), it gets reset to all zeroes for obvious security reasons (although it may not happen instantaneously, but no other legitimate processes will be able to access that memory until after it was cleared).

Note: about memory, there is also the issue of VMs and the possibility that some data can leak between processes running in a virtual environment.

One of my CPUs has the following bugs:

bugs: spectre_v1 spectre_v2 spec_store_bypass swapgs taa itlb_multihit mmio_stale_data

To see your CPUs bug under Linux, you can do the following:

less /proc/cpuinfo

and search for "bugs".

Search on those names for more details about each one of them. As an FYI, these are quite difficult to temper with bugs so in most likelihood you're safe.

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.