Viml quickfix/loclist: Difference between revisions

From wikinotes
 
 
(One intermediate revision by the same user not shown)
Line 18: Line 18:
" append 'items' to quickfix list  ('a')
" append 'items' to quickfix list  ('a')
call setqflist(
call setqflist(
     \ [],  
     \ [],
     \ 'a',
     \ 'a',
     \ {'items': [
     \ {'items': [
Line 26: Line 26:
\ )
\ )


call setqflist([], 'a', { 'items': [{'filename': $HOME.'/.vimrc'}] })
</source>


</source>
<syntaxhighlight lang="vim">
:call setqflist([], ' ', {'lines': systemlist('grep -Hn main *.c')})  " populate with grep output
</syntaxhighlight>


= Syntax =
= Syntax =

Latest revision as of 19:35, 26 June 2022

Vim's quickfix is a global window that you can populate and use to jump between files.

Vim's loclist is a window-specific window that behaves the same as quickfix (except not being global).

Documentation

asynchronous updates to quickfix/loclist https://gist.github.com/yegappan/3b50ec9ea86ad4511d3a213ee39f1ee0

Usage

See :help setqflist-examples for lots of examples.

:copen               " open quickfix
:call setqflist([])  " clear quickfix

" append 'items' to quickfix list  ('a')
call setqflist(
    \ [],
    \ 'a',
    \ {'items': [
        \ {'filename': 'taskmage2/project/taskfiles.py', 'lnum': 20, 'text': 'blah blah blah'}
        \ ]
    \ }
\ )

call setqflist([], 'a', { 'items': [{'filename': $HOME.'/.vimrc'}] })
:call setqflist([], ' ', {'lines': systemlist('grep -Hn main *.c')})  " populate with grep output

Syntax

" /path|line-number|message
/path/to/file.txt|34|my message