Create the file in ~/.vim/ftplugin/qf.vim
(or $HOME/vimfiles/ftplugin/qf.vim
if you are on Windows) with the following contents:
" Only do this when not done yet for this buffer
if exists("b:did_ftplugin")
finish
endif
wincmd p " go to original window
set cursorline
set cursorcolumn
wincmd p " back to quickfix window
The ftplugin files are executed whenever the filetype is set for a given file buffer (quickfix and location window has the filetyp qf
).
Using the filetype plugin files instead of autocmds avoids cluttering your vimrc.
You can find more details at :help ftplugin-name
, :help 43
and Vim FAQ 26.8.
Edit:
The check on b:did_ftplugin
is necessary to allow disabling it if necessary and to avoid loading it twice (see :help ftplugin
).
The let b:did_ftplugin = 1
is omitted from this file because the intent of this file is to increment the default filetype plugin for quickfix, and not override. If this line was added then the settings at $VIMRUNTIME/ftplugin/qf.vim
would be skipped, as explained at :help ftplugin-overrule
.
:h QuickFixCmdPost
) instead but I'm not sure that would be better.Ack
,vimgrep
and so on. But it doesn't work in the case of:copen
. Quite nice solution!:h QuickFixCmdPre
it contains a list of the commands triggering the eventQuickFixCmdPre
(and thus the eventQuickFixCmdPost
) and indeed:copen
is not one of them. So the behavior you're experiencing is normal but I don't know how to make it work with:copen
...