diff --git a/after/ftplugin/qf.vim b/after/ftplugin/qf.vim index 67bc058..73742cf 100644 --- a/after/ftplugin/qf.vim +++ b/after/ftplugin/qf.vim @@ -136,6 +136,11 @@ nnoremap :call qf#history#Newer() nnoremap } :call qf#filegroup#NextFile() nnoremap { :call qf#filegroup#PreviousFile() +if !b:qf_isLoc + nnoremap ':wincmd p '.line('.').'cc' + let b:undo_ftplugin .= "| execute 'nunmap '" +endif + " quit Vim if the last window is a quickfix window autocmd qf BufEnter nested if get(g:, 'qf_auto_quit', 1) | if winnr('$') < 2 | q | endif | endif autocmd qf BufWinEnter nested if get(g:, 'qf_auto_quit', 1) | call qf#filter#ReuseTitle() | endif diff --git a/plugin/qf.vim b/plugin/qf.vim index a876262..da4d431 100644 --- a/plugin/qf.vim +++ b/plugin/qf.vim @@ -61,9 +61,13 @@ augroup qf " automatically open the location/quickfix window after :make, :grep, " :lvimgrep and friends if there are valid locations/errors - autocmd QuickFixCmdPost [^l]* nested call qf#OpenQuickfix() - autocmd QuickFixCmdPost l* nested call qf#OpenLoclist() - autocmd VimEnter * nested call qf#OpenQuickfix() + autocmd QuickFixCmdPre * nested let s:qflist = getqflist() + autocmd QuickFixCmdPost * nested exe 'call qf#Open' . (s:qflist == getqflist() ? 'Loclist' : 'Quickfix') . '()' + autocmd VimEnter * nested call qf#OpenQuickfix() + + " stop vim from jumping to the last window before opening the first entry + autocmd QuickFixCmdPre * nested let s:winnr = winnr() + autocmd QuickFixCmdPost * nested exe s:winnr 'wincmd w' " automatically close corresponding loclist when quitting a window if exists('##QuitPre')