2

I want to be able to create a new buffer (and a new window with which to interact with it) to work with secret or sensitive info, e.g. passwords.

Ideally, none of the contents of the buffer would persist after it's closed or discarded. It'd probably be best if the contents are discarded too even when the last window for the buffer is closed. If possible, it'd be best if any in-memory copies of the buffer are 'wiped' when it's closed as well.

The gnupg.vim plugin claims:

The script turns off viminfo and swapfile to increase security.

So doing both seems necessary, tho perhaps not sufficient. What else should I do?

1
  • 1
    Maybe also ensuring that undofile is off, although it's off by default. Also maybe setting buftype to nofile. These are just some things that come to mind, but security is not my expertise.
    – Tumbler41
    Commented Apr 24, 2017 at 16:10

1 Answer 1

1

In this case i would

:new
:setlocal buftype=nofile
:setlocal bufhidden=hide
:setlocal noswapfile

buftype=nofile does not associate the buffer with a file.

noswapfile does not create a swapfile.

bufhidden=hide hides the buffer, when its windows is closed.

Vim discards the content in the buffer on exit without warning.

If you like to clear it before, you can use :bw to wipe the buffer.

There also is a plugin for that, however, I haven't tried this one.

I would also like to add, that I'm not a security expert, and there conceivably are a number of ways to access that information.

3
  • 1
    I would rather use set bufhidden=wipe and additionally to make sure :setl noundofiles and perhaps disable the modeline (however that would need to be done globally). Depending on what you want, you can also conceal parts of the text so that one does not immediately see what is on your screen. Commented Apr 25, 2017 at 7:55
  • How do you conceal parts of the text?
    – mike
    Commented Apr 25, 2017 at 8:00
  • using either custom syntax rules or some :matchadd() calls. Commented Apr 25, 2017 at 8:20

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.