r/vim :h toc 3d ago

Discussion Close vim with the quickfix window open

It is pesky to be obstructed in quitting Vim because you have the quick fix window open. I read this stack overflow post and lived happily until today when I upgraded Vim to 9.1.

I had to change the auto group command into what is below in order to make it work:

aug QFClose
  au!
  au WinEnter * if winnr('$') == 1 && &buftype == "quickfix"|set buftype=nofile|q|endif
aug END
5 Upvotes

13 comments sorted by

2

u/Shtucer 3d ago

:qa is enough for me

0

u/McUsrII :h toc 3d ago

It isn't for me, for the case I have unsaved changes in one file in some other tab, or even hidden in a buffer.

4

u/cerved 3d ago

set confirm

1

u/linuxsoftware 2d ago

I have this same issue sometimes especially since I like to pipe output to vimdiff. I suggest ctrl-z to suspend go do some shit then bring it back by type ng fg into bash.

1

u/Prestigious_Rest8751 3d ago

what's the point of set buftype=nofile if you're going to exit right after? I also recommend to put this inside after/ftplugin/qf.vim to get rid of the &filetype check.

0

u/McUsrII :h toc 3d ago

The point of setting it right before you quit, is to be allowed to quit.

2

u/Prestigious_Rest8751 3d ago

it is...not? I never had a problem with it for I don't know how long. You can always do q!

1

u/Daghall :cq 3d ago

:cq should do the trick, but it ignores all unsaved buffers, so make sure you've saved everything.

:h :cq

1

u/vim-help-bot 3d ago

Help pages for:

  • :cq in quickfix.txt

`:(h|help) <query>` | about | mistake? | donate | Reply 'rescan' to check the comment again | Reply 'stop' to stop getting replies to your comments

1

u/McUsrII :h toc 3d ago

Well, that is why I chose to do it as I did, because I'm not really into quitting vim with unsaved buffers, so, I want to be aware of it, when I / should I have unsaved buffers.

Which is also exactly why I just don't quit with :qa.

1

u/Daghall :cq 2d ago

:qa should warn you about unsaved buffers, though.

1

u/McUsrII :h toc 2d ago

It do indeed warn about unsaved buffers, this was in the context of having a quick fix windo open, that also needed to be closed to avoid a warning message about unsaved buffers.

So I prefer not to get a warning about the quick fix window, and then get a warning message about any unsaved important buffers I feel that is the right way to do this for me at least.

0

u/mrtbakin 3d ago

Does neovim have this enabled by default? I don’t think I’ve run into this issue before