Created
September 6, 2019 20:22
-
-
Save qstrahl/121d632493e24b0ec67949730520a7f0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! s:map () | |
map <buffer> <Return> <Cmd>exe 'wincmd p \|' line('.') 'cc'<CR> | |
endfunction | |
function! s:unmap () | |
unmap <buffer> <Return> | |
endfunction | |
function! s:list () | |
return expand('<amatch>')[0] == 'l' ? getloclist(0) : getqflist() | |
endfunction | |
autocmd! QuickFixCmdPost * if !empty(s:list()) | wincmd p | endif | |
autocmd! BufWinEnter * if &buftype == 'quickfix' | call s:map() | endif | |
autocmd! BufWinLeave * if &buftype == 'quickfix' | call s:unmap() | endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment