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".

  • 3
    Are you sure you are reopening the file (:e) instead of just hiding and unhiding a buffer?
    – jw013
    Commented Aug 4, 2011 at 1:39
  • @jw013 Good point. It really puzzled me, how the behavior can be possible since the swap file is also encrypted. Commented Aug 4, 2011 at 6:06
  • Are you using gvim or some other GUI variant? If so which one and on what platform?
    – Caleb
    Commented Aug 4, 2011 at 10:10
  • @Caleb I'm using gvim on Ubuntu 11.04 (package vim-gnome)
    – ivotron
    Commented Aug 6, 2011 at 22:09
  • 1
    @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
    Commented Aug 7, 2011 at 16:21

1 Answer 1


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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .