Ad blocker interference detected!
Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers
Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.
created 2003 · complexity intermediate · author David Kalita · version 6.0
Usually I have open one window with source code and one with error codes (command
:copen). When I quit the source code quickfix window stays open. The following causes the quickfix window to close automatically.
au BufEnter * call MyLastWindow() function! MyLastWindow() " if the window is quickfix go on if &buftype=="quickfix" " if this window is last on screen quit without warning if winbufnr(2) == -1 quit! endif endif endfunction
The quit! should be changed to tabclose to be safe.
- I don't think your concern is correct. The
quit!would close the current buffer and discard any changes for that buffer. However, the command does not attempt to close any other buffer, so unsaved work in other tabs will be retained (Vim will not terminate).
- Is the
!needed? I think you have to go to a fair bit of trouble to make a change to a quickfix window, so a plain
quitwould suffice and be a tiny bit safer.
- Rather than use
winbufnr(2), I think the test could be
if winnr('$') < 2. JohnBeckett 07:00, May 10, 2011 (UTC)