4

How can set BufEnter or WinEnter autocmds for entering quickfix window?

I tried

autocmd WinEnter quickfix echo 'winenter'
autocmd BufEnter quickfix echo 'bufenter'

None of them works. I doubt that it is because these two commands needs file name after the event name. Then what is the file pattern for quickfix window?

I have fugitive installed. By filling the quickfix window using Glog, the statusline for the quickfix window shows something like [:git --git-dir=...] [Quickfix List]. Is this the filename of the quickfix buffer which should be used in the pattern of the BufEnter/WinEnter event?

I cannot see anything if I echo @% which should usually show the current bufname.

5

The parameter for both the WinEnter and BufEnter events are matched against the buffer name, which is empty for the quickfix window:

:echo bufname('')
[no output]

You can still use the buftype variable though:

autocmd WinEnter * if &buftype == 'quickfix' | echo 'winenter' | endif
2

Just remark to Martin Tournoij answer. When you just open quickfix buffer/window (not switch from another buffer/window) &buftype variable isn't setted yet, so may be useful one more autocmd handler:

autocmd BufWinEnter quickfix echo 'bufwinenter'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.