Monday, October 31, 2011

Re: detect QuickFix window list or LocationList

On 10/31/11 06:14, stardiviner wrote:
> 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

(I presume those 2nd mappings should be <A-p> to prevent
overwriting the previous mapping...)

A rough (untested) pair of mappings might look something like

:nnoremap <expr> <A-n> (&buftype=='quickfix'?':cn':':lnext')."\n"

:nnoremap <expr> <A-p> (&buftype=='quickfix'?':cp':':lprev')."\n"


Adjust accordingly for your intent regarding the logic. It might
end up looking something like


':'.((&buftype=='quickfix'?'cn':(&buftype=='location'?'lnext':'n'))."\n"

to treat all 3 cases (qf, loc, and other).

-tim


--
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: