From :help :q
:q[uit]
:{count}q[uit] *:count_quit*
CTRL-W q *CTRL-W_q*
CTRL-W CTRL-Q *CTRL-W_CTRL-Q*
Without {count}: Quit the current window. If {count} is
given quit the {count} window.
*edit-window*
When quitting the last edit window (not counting help or
preview windows), exit Vim.
When 'hidden' is set, and there is only one window for the
current buffer, it becomes hidden. When 'hidden' is not set,
and there is only one window for the current buffer, and the
buffer was changed, the command fails.
(Note: CTRL-Q does not work on all terminals).
If [count] is greater than the last window number the last
window will be closed: >
:1quit " quit the first window
:$quit " quit the last window
:9quit " quit the last window
" if there are fewer than 9 windows opened
:-quit " quit the previous window
:+quit " quit the next window
:+2quit " quit the second next window
<
When closing a help window, and this is not the only window,
Vim will try to restore the previous window layout, see
|:helpclose|.
Emphasis on
When 'hidden' is set, and there is only one window for the
current buffer, it becomes hidden. When 'hidden' is not set,
and there is only one window for the current buffer, and the
buffer was changed, the command fails.
So the solution sounds like you want the :set nohidden
behavior.
'hidden'
option, but note that vim doesn't really have a concept of "closing files." There are only buffers, windows, and tabs. You also don't close a buffer: you can load, view, modify, write, unload, delete, and wipe them. With that, it's hard for me to understand what you're asking.:q
a buffer, vim seems to just hide the buffer instead of closing it. And in this case, it also keeps the swap file intact so other vim processes trying to open the file show the warning about the swap file existing.:help windows.txt
and around:help hidden-buffer
. You can completely get rid of a buffer (:bunload
,:bdelete
,:bwipeout
). One or more of those should help get rid of the swap file, at least.