0}).context
" get the location list window id of the third window
:echo getloclist(3, {'winid' : 0}).winid
" get the location list window buffer number of the third window
:echo getloclist(3, {'qfbufnr' : 0}).qfbufnr
" get the file window id of a location list window (winnr: 4)
:echo getloclist(4, {'filewinid' : 0}).filewinid
<
*setqflist-examples*
The |setqflist()| and |setloclist()| functions can be used to set the various
attributes of a quickfix and location list respectively. Some examples for
using these functions are below:
>
" create an empty quickfix list with a title and a context
:let t = 'Search results'
:let c = {'cmd' : 'grep'}
:call setqflist([], ' ', {'title' : t, 'context' : c})
" set the title of the current quickfix list
:call setqflist([], 'a', {'title' : 'Mytitle'})
" change the current entry in the list specified by an identifier
:call setqflist([], 'a', {'id' : qfid, 'idx' : 10})
" set the context of a quickfix list specified by an identifier
:call setqflist([], 'a', {'id' : qfid, 'context' : {'val' : 100}})
" create a new quickfix list from a command output
:call setqflist([], ' ', {'lines' : systemlist('grep -Hn main *.c')})
" parse text using a custom efm and add to a particular quickfix list
:call setqflist([], 'a', {'id' : qfid,
\ 'lines' : ["a.c#10#L10", "b.c#20#L20"], 'efm':'%f#%l#%m'})
" add items to the quickfix list specified by an identifier
:let newItems = [{'filename' : 'a.txt', 'lnum' : 10, 'text' : "Apple"},
\ {'filename' : 'b.txt', 'lnum' : 20, 'text' : "Orange"}]
:call setqflist([], 'a', {'id' : qfid, 'items' : newItems})
" empty a quickfix list specified by an identifier
:call setqflist([], 'r', {'id' : qfid, 'items' : []})
" free all the quickfix lists in the stack
:call setqflist([], 'f')
" set the title of the fourth quickfix list
:call setqflist([], 'a', {'nr' : 4, 'title' : 'SomeTitle'})
" create a new quickfix list at the end of the stack
:call setqflist([], ' ', {'nr' : '$',
\ 'lines' : systemlist('grep -Hn class *.java')})
" create a new location list from a command output
:call setloclist(0, [], ' ', {'lines' : systemlist('grep -Hn main *.c')})
" replace the location list entries for the third window
:call setloclist(3, [], 'r', {'items' : newItems})
<
=============================================================================
3. Using more than one list of errors *quickfix-error-lists*
So far it has been assumed that there is only one list of errors. Actually
there can be multiple used lists that are remembered; see 'chistory' and
'lhistory'.
When starting a new list, the previous ones are automatically kept. Two
commands can be used to access older error lists. They set one of the
existing error lists as the current one.
*:colder* *:col* *E380*
:col[der] [count] Go to older error list. When [count] is given, do
this [count] times. When already at the oldest error
list, an error message is given.
*:lolder* *:lol*
:lol[der] [count] Same as `:colder`, except use the location list for
the current window instead of the quickfix list.
*:cnewer* *:cnew* *E381*
:cnew[er] [count] Go to newer error list. When [count] is given, do
this [count] times. When already at the newest error
list, an error message is given.
*:lnewer* *:lnew*
:lnew[er] [count] Same as `:cnewer`, except use the location list for
the current window instead of the quickfix list.
*:chistory* *:chi*
:[count]chi[story] Show the list of error lists. The current list is
marked with ">". The output looks like: >
error list 1 of 3; 43 errors :make
> error list 2 of 3; 0 errors :helpgrep tag
error list 3 of 3; 15 errors :grep ex_help *.c
<
When [count] is given, then the count'th quickfix
list is made the current list. Example: >
" Make the 4th quickfix list