0

Is there a setting that will allow you to just close the window without bothering with the save changes dialog when you exit?

Do you have to attach it to an event that answers for you?

3 Answers 3

1

This is standard behavior, shared by all the document-oriented GUI apps on your Desktop. The feature is provided by the GUI toolkit used to build GVim so I don't think there is a GVim-specific way to really change that behavior except, maybe, digging through the code and compiling it the way you like.

However, Vim, as a modal editor, kind of encourages explicitness and precision with all its commands. In this case, the proper Ex command for forcibly closing the current GUI window would be :qa!.

That said, you can try to map <C-w> to :qa!<CR>, but I just tried it with <D-w> in MacVim and it didn't work at all.

If I were you, I would go with :qa!.

2

I would not generally recommend it, because the risk to lose data is way too high, but since you ask for it:

:au QuitPre * :bw!

This will basically abort the current buffer when using :q and if this is the last window it will automatically quit. An even more radical solution would be to wipe all buffers, which would then quit Vim even when there are several windows/tabpages open. But I won't spell it out explicitly, because I think this is too risky in my opinion.

0

Let's look at this from a different angle: Vim asks to save if there are changes to a buffer. You can make sure there are none by automatically writing all changes to file.

There's the (currently unmaintained) plugin vim-auto-save and an old SO question how to save a file every 1 second in vim? to that effect. There's also an autosave option on vim's todo list.

Obvious side effect: whatever you type ends up in the file.

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.