summaryrefslogtreecommitdiffstats
path: root/runtime/doc/quickfix.txt
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-04-30 22:19:58 +0200
committerBram Moolenaar <Bram@vim.org>2018-04-30 22:19:58 +0200
commit15142e27aaafa15b72d1042c25fbb5e4f12b6736 (patch)
tree21550bf13f98f3aae0b64660616b1029df654340 /runtime/doc/quickfix.txt
parent77bfd756a02c3b3150d6c08ddbf89b66362dad8d (diff)
Update runtime files and translations
Diffstat (limited to 'runtime/doc/quickfix.txt')
-rw-r--r--runtime/doc/quickfix.txt92
1 files changed, 91 insertions, 1 deletions
diff --git a/runtime/doc/quickfix.txt b/runtime/doc/quickfix.txt
index e627686bfc..de80c68adf 100644
--- a/runtime/doc/quickfix.txt
+++ b/runtime/doc/quickfix.txt
@@ -1,4 +1,4 @@
-*quickfix.txt* For Vim version 8.0. Last change: 2018 Mar 29
+*quickfix.txt* For Vim version 8.0. Last change: 2018 Apr 28
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -597,6 +597,96 @@ present). Examples: >
echo getqflist({'winid' : 1}).winid
echo getloclist(2, {'winid' : 1}).winid
<
+ *getqflist-examples*
+The getqflist() and getloclist() functions can be used to get the various
+attributes of a quickfix and location list respectively. Some examples for
+using these functions are below:
+>
+ " get the title of the current quickfix list
+ :echo getqflist({'title' : 0}).title
+
+ " get the identifier of the current quickfix list
+ :let qfid = getqflist({'id' : 0}).id
+
+ " get the index of the current quickfix list in the stack
+ :let qfnum = getqflist({'nr' : 0}).nr
+
+ " get the items of a quickfix list specified by an identifier
+ :echo getqflist({'id' : qfid, 'items' : 0}).items
+
+ " get the number of entries in a quickfix list specified by an id
+ :echo getqflist({'id' : qfid, 'size' : 0}).size
+
+ " get the context of the third quickfix list in the stack
+ :echo getqflist({'nr' : 3, 'context' : 0}).context
+
+ " get the number of quickfix lists in the stack
+ :echo getqflist({'nr' : '$'}).nr
+
+ " get the number of times the current quickfix list is changed
+ :echo getqflist({'changedtick' : 0}).changedtick
+
+ " get the current entry in a quickfix list specified by an identifier
+ :echo getqflist({'id' : qfid, 'idx' : 0}).idx
+
+ " get all the quickfix list attributes using an identifier
+ :echo getqflist({'id' : qfid, 'all' : 0})
+
+ " parse text from a List of lines and return a quickfix list
+ :let myList = ["a.java:10:L10", "b.java:20:L20"]
+ :echo getqflist({'lines' : myList}).items
+
+ " parse text using a custom 'efm' and return a quickfix list
+ :echo getqflist({'lines' : ['a.c#10#Line 10'], 'efm':'%f#%l#%m'}).items
+
+ " get the quickfix list window id
+ :echo getqflist({'winid' : 0}).winid
+
+ " get the context of the current location list
+ :echo getloclist(0, {'context' : 0}).context
+
+ " get the location list window id of the third window
+ :echo getloclist(3, {'winid' : 0}).winid
+<
+ *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:
+>
+ " set the title of the current quickfix list
+ :call setqflist([], 'a', {'title' : 'Mytitle'})
+
+ " 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})
+
+ " 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*