2

I have two windows that I created with a :vsplit. Window 1 displays a file with changes that have not been saved yet, Window 2 displays another file.

I want to get rid of Window 1, so I type :only in Window 2. However, vim complains that E445: Other window contains changes and refuses to proceed.

I appreciate that it tells me this but I don't understand why it doesn't proceed. I'm not leaving, why should it care?

1
  • Notice that Vim's session also stores slient only on line 4, which might introduce this error. Feb 14 at 3:09

2 Answers 2

3

Vim doesn't close the windows because you don't have either of the 'hidden' or 'autowrite' options set (which indicates to Vim that you don't want windows with unsaved changes to be easily closable).

:help :only (or :help E445) gives more details:

When the 'hidden' option is set, all buffers in closed windows become hidden.

When 'hidden' is not set, and the 'autowrite' option is set, modified buffers are written. Otherwise, windows that have buffers that are modified are not removed, unless the [!] is given, then they become hidden. But modified buffers are never abandoned, so changes cannot get lost.

See also :help hidden-buffers for more details of how Vim handles this.

1

Vim generally has a policy of not getting rid of windows with changes unless you force it with !.

:only!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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