Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If I run Vim and then open an encrypted file it asks for the encryption password. If I close the window where the file was opened (without closing vim) and then reopen the file, the password prompt is not shown anymore. Is there any setting to modify this behavior? I'd like vim to ask the password every time the file is opened regardless if it's the same Vim "session".

share|improve this question
Are you sure you are reopening the file (:e) instead of just hiding and unhiding a buffer? – jw013 Aug 4 '11 at 1:39
@jw013 Good point. It really puzzled me, how the behavior can be possible since the swap file is also encrypted. – rozcietrzewiacz Aug 4 '11 at 6:06
Are you using gvim or some other GUI variant? If so which one and on what platform? – Caleb Aug 4 '11 at 10:10
@Caleb I'm using gvim on Ubuntu 11.04 (package vim-gnome) – ivotron Aug 6 '11 at 22:09
@ivotron: :q only closes a window - if you have 'hidden'set the buffer simply becomes hidden - the file is not actually closed. Use :ls or :buffers to list all buffers. – jw013 Aug 7 '11 at 16:21
up vote 6 down vote accepted

According to the vim documentation, :q closes the current window and only quits if there are no windows left. In vim, windows are merely "viewports" where buffers can be displayed. The vim documentation itself sums this up quite nicely. From :help window:

A buffer is the in-memory text of a file.
A window is a viewport on a buffer.
A tab page is a collection of windows.

If you have the hidden option set, closing a window hides the buffer but does not "abandon" it, so vim is still keeping track of the contents. With 'hidden' set, when you "reopen" the file, you are simply re-showing/un-hiding the buffer, not actually re-opening the file on disk.

For more information take a look at

:help hidden
:help abandon
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.