Closed jeromedalbert closed 5 years ago
Here are two things you could try:
:w
instead of :wa
and keep excluding quickfix-
buffer names. Should still work. Assuming you don't use operations that modify buffers in multiple windows simultaneously.:update
instead of :write
. If you absolutely need to write buffers in multiple windows, you could do :windo update
.Thanks for the pointers!
I want to keep using :wa
so that autowriting works even when switching tabs. And windo :update
will sometimes write to the quicklist buffer when the buffer is modified.
After some poking around, I ended up with the following code:
function! Autowrite()
for tabnum in range(tabpagenr('$'))
for bufnum in tabpagebuflist(tabnum + 1)
if bufname(bufnum) =~ '^quickfix-' | return | endif
endfor
endfor
silent! wa
endfunction
This basically disables autowriting if the quickfix list is open anywhere in Vim. This is good enough behavior for me, as I never leave the quickfix list open for very long. I could further improve by falling back to single-file :w
autowriting if needed.
I have this handy bit of code that autowrites files when focus is lost:
However, this also writes the quickfix buffer to a file if I have it open and change focus. For now I was able to mitigate with
But this only works if the current buffer is the quickfix list. If I switch to another buffer, it will still write the file.
Is there some way to prevent this? Maybe somehow prevent the quickfix list to ever be written to a file?