0

I wrote a plugin that executes a slow shell script and asynchronously shows the stdout in a popup (split) window. When I try to close my session while the popup is open, I get the message

Save changes to "popup.log"?
[Y]es, (N)o, (C)ancel

How can I automatically reject changes to this temporary buffer without rejecting changes to the files I am actually editing (as would happen with :qa!)?

Is there some buffer-local option I can set that allows the buffer to changes but specifies "this is a temporary buffer, but never ever ask me to save changes"? Seems like lots of vim plugins do this (tagbar, NERDtree, etc.) but I don't know how.

2
  • setlocal buftype=nofile noswapfile. See :h special-buffers.
    – Matt
    Commented Oct 15, 2019 at 3:49
  • @Matt Thanks! Could you post this as an answer so I can accept?
    – Luke Davis
    Commented Oct 15, 2019 at 4:12

1 Answer 1

1

Is there some buffer-local option I can set that allows the buffer to changes but specifies "this is a temporary buffer, but never ever ask me to save changes"?

The most essential one is buftype=nofile. Also, :h special-buffers recommends using noswapfile (nowadays often switched off globally) and bufhidden=hide (so a buffer can be reused after :quit-ting the window; but note that ZQ and :quit! still drop it completely). As following these recommendations does not seem to hurt, you can do

setlocal buftype=nofile bufhidden=hide noswapfile

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.