> I want to bind key Alt-n/p to next/previous LocationList or next/previous QuickFix list.
> So I need to detect which List in current buffer. then bind Alt-n/p to them.
> like this.
> if (detect Location or QuickFix)
> map<A-n> :cnext<CR>
> map<A-n> :cprevious<CR>
> elseif
> map<A-n> :lnext<CR>
> map<A-n> :lprevious<CR>
> endif
You could check for
empty(getloclist(0))
" Second approach: always do :lnext and if that fails, try :cnext
nnoremap <A-n> :NextError<CR>
nnoremap <A-p> :PrevError<CR>
com! -bar NextError call s:GoForError("next")
com! -bar PrevError call s:GoForError("previous")
func! s:GoForError(partcmd)
try
try
exec "l". a:partcmd
catch /:E776:/
" No location list
exec "c". a:partcmd
endtry
catch
echohl ErrorMsg
echomsg matchstr(v:exception, ':\zs.*')
echohl None
endtry
endfunc
--
Andy
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
No comments:
Post a Comment