robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

robinmerge: 1dc9728daa1d8a2702

master
101.5 KiB2524 linesraw
1*quickfix.txt*  Nvim
2
3
4		  VIM REFERENCE MANUAL	  by Bram Moolenaar
5
6
7This subject is introduced in section |30.1| of the user manual.
8
9                                      Type |gO| to see the table of contents.
10
11=============================================================================
121. Using QuickFix commands			*quickfix* *Quickfix* *E42*
13
14Vim has a special mode to speedup the edit-compile-edit cycle.  This is
15inspired by the quickfix option of the Manx's Aztec C compiler on the Amiga.
16The idea is to save the error messages from the compiler in a file and use Vim
17to jump to the errors one by one.  You can examine each problem and fix it,
18without having to remember all the error messages.
19
20In Vim the quickfix commands are used more generally to find a list of
21positions in files.  For example, |:vimgrep| finds pattern matches.  You can
22use the positions in a script with the |getqflist()| function.  Thus you can
23do a lot more than the edit/compile/fix cycle!
24
25If you have the error messages in a file you can start Vim with: >
26	vim -q filename
27
28From inside Vim an easy way to run a command and handle the output is with the
29|:make| command (see below).
30
31The 'errorformat' option should be set to match the error messages from your
32compiler (see |errorformat| below).  Vim uses it to extract information such
33as the file name, line number and message from each line of compiler output.
34Lines that do not match are kept as invalid entries and are skipped by
35commands such as |:cnext|.  Use |:clist|! to display them as well.
36
37					*quickfix-stack* *quickfix-ID*
38Each quickfix list has a unique identifier called the quickfix ID and this
39number will not change within a Vim session.  The |getqflist()| function can be
40used to get the identifier assigned to a list.  There is also a quickfix list
41number, which is its position in the quickfix stack.  This number may change
42when lists are added or removed, or when more than 'chistory' lists are kept.
43Use the ID when a script needs to refer to the same list reliably; use the
44list number when referring to its current position in the stack.
45
46						*location-list* *E776*
47A location list is a quickfix list tied to one window.  Each window can have a
48separate location list, and commands such as `:lvimgrep`, `:lgrep`,
49`:lhelpgrep` and `:lmake` use it instead of the global quickfix list.  The
50corresponding commands without the "l" prefix use the quickfix list.
51						*location-list-file-window*
52The location list is independent of the quickfix list.  A location list can
53be associated with only one window.
54
55When a window with a location list is split, the new window gets a copy of the
56location list.  When there are no longer any references to a location list,
57the location list is destroyed.
58
59						*quickfix-changedtick*
60Every quickfix and location list has a read-only changedtick variable that
61tracks the total number of changes made to the list.  Every time the quickfix
62list is modified, this count is incremented.  This can be used to perform an
63action only when the list has changed.  The |getqflist()| and |getloclist()|
64functions can be used to query the current value of changedtick.  You cannot
65change the changedtick variable.
66
67The following quickfix commands can be used.  The location list commands are
68similar to the quickfix commands, replacing the 'c' prefix in the quickfix
69command with 'l'.
70
71							*E924*
72If the current window was closed by an |autocommand| while processing a
73location list command, it will be aborted.
74
75							*E925* *E926*
76If the current quickfix or location list was changed by an |autocommand| while
77processing a quickfix or location list command, it will be aborted.
78
79							*:cc*
80:cc[!] [nr]		Display error [nr].  If [nr] is omitted, the same
81:[nr]cc[!]		error is displayed again.  Without [!] this doesn't
82			work when jumping to another buffer, the current
83			buffer has been changed, there is the only window for
84			the buffer and both 'hidden' and 'autowrite' are off.
85			When jumping to another buffer with [!] any changes to
86			the current buffer are lost, unless 'hidden' is set or
87			there is another window for this buffer.
88			The 'switchbuf' settings are respected when jumping
89			to a buffer.
90			When used in the quickfix window the line number can
91			be used, including "." for the current line and "$"
92			for the last line.
93
94							*:ll*
95:ll[!] [nr]		Same as ":cc", except the location list for the
96:[nr]ll[!]		current window is used instead of the quickfix list.
97
98						*:cn* *:cne* *:cnext* *E553*
99:[count]cn[ext][!]	Display the [count] next error in the list that
100			includes a file name.  Entries without a file name are
101			skipped, since Vim cannot use them to jump to a file.
102			If there are no file names at all, go to the [count]
103			next error.  See |:cc| for [!] and 'switchbuf'.
104
105								*]q*
106]q			Mapped to |:cnext|. |default-mappings|
107
108:[count]cN[ext][!]		*:cp* *:cprevious*  *:cprev* *:cN* *:cNext*
109:[count]cp[revious][!]	Display the [count] previous error in the list that
110			includes a file name.  Entries without a file name are
111			skipped, since Vim cannot use them to jump to a file.
112			If there are no file names at all, go to the [count]
113			previous error.  See |:cc| for [!] and 'switchbuf'.
114
115								*[q*
116[q			Mapped to |:cprevious|. |default-mappings|
117
118							*:lne* *:lnext*
119:[count]lne[xt][!]	Same as ":cnext", except the location list for the
120			current window is used instead of the quickfix list.
121
122								*]l*
123]l			Mapped to |:lnext|. |default-mappings|
124
125
126:[count]lN[ext][!]		*:lp* *:lprevious* *:lprev* *:lN* *:lNext*
127:[count]lp[revious][!]	Same as ":cNext" and ":cprevious", except the location
128			list for the current window is used instead of the
129			quickfix list.
130
131								*[l*
132[l			Mapped to |:lprevious|. |default-mappings|
133
134							*:cabo* *:cabove*
135:[count]cabo[ve]	Go to the [count] error above the current line in the
136			current buffer.  If [count] is omitted, then 1 is
137			used.  If there are no errors, then an error message
138			is displayed.  Assumes that the entries in a quickfix
139			list are sorted by their buffer number and line
140			number.  If there are multiple errors on the same
141			line, then only the first entry is used.  If [count]
142			exceeds the number of entries above the current line,
143			then the first error in the file is selected.
144
145							*:lab* *:labove*
146:[count]lab[ove]	Same as ":cabove", except the location list for the
147			current window is used instead of the quickfix list.
148
149							*:cbel* *:cbelow*
150:[count]cbel[ow]	Go to the [count] error below the current line in the
151			current buffer.  If [count] is omitted, then 1 is
152			used.  If there are no errors, then an error message
153			is displayed.  Assumes that the entries in a quickfix
154			list are sorted by their buffer number and line
155			number.  If there are multiple errors on the same
156			line, then only the first entry is used.  If [count]
157			exceeds the number of entries below the current line,
158			then the last error in the file is selected.
159
160							*:lbel* *:lbelow*
161:[count]lbel[ow]	Same as ":cbelow", except the location list for the
162			current window is used instead of the quickfix list.
163
164							*:cbe* *:cbefore*
165:[count]cbe[fore]	Go to the [count] error before the current cursor
166			position in the current buffer.  If [count] is
167			omitted, then 1 is used.  If there are no errors, then
168			an error message is displayed.  Assumes that the
169			entries in a quickfix list are sorted by their buffer,
170			line and column numbers.  If [count] exceeds the
171			number of entries before the current position, then
172			the first error in the file is selected.
173
174							*:lbe* *:lbefore*
175:[count]lbe[fore]	Same as ":cbefore", except the location list for the
176			current window is used instead of the quickfix list.
177
178							*:caf* *:cafter*
179:[count]caf[ter]	Go to the [count] error after the current cursor
180			position in the current buffer.  If [count] is
181			omitted, then 1 is used.  If there are no errors, then
182			an error message is displayed.  Assumes that the
183			entries in a quickfix list are sorted by their buffer,
184			line and column numbers.  If [count] exceeds the
185			number of entries after the current position, then
186			the last error in the file is selected.
187
188							*:laf* *:lafter*
189:[count]laf[ter]	Same as ":cafter", except the location list for the
190			current window is used instead of the quickfix list.
191
192							*:cnf* *:cnfile*
193:[count]cnf[ile][!]	Display the first error in the [count] next file in
194			the list that includes a file name.  If there are no
195			file names at all or if there is no next file, go to
196			the [count] next error.  See |:cc| for [!] and
197			'switchbuf'.
198
199							*]_CTRL-Q*
200]_CTRL-Q		Mapped to |:cnfile|. |default-mappings|
201
202							*:lnf* *:lnfile*
203:[count]lnf[ile][!]	Same as ":cnfile", except the location list for the
204			current window is used instead of the quickfix list.
205
206							*]_CTRL-L*
207]_CTRL-L			Mapped to |:lnfile|. |default-mappings|
208
209:[count]cNf[ile][!]			*:cpf* *:cpfile* *:cNf* *:cNfile*
210:[count]cpf[ile][!]	Display the last error in the [count] previous file in
211			the list that includes a file name.  If there are no
212			file names at all or if there is no next file, go to
213			the [count] previous error.  See |:cc| for [!] and
214			'switchbuf'.
215
216								*[_CTRL-Q*
217[_CTRL-Q		Mapped to |:cpfile|. |default-mappings|
218
219
220:[count]lNf[ile][!]			*:lpf* *:lpfile* *:lNf* *:lNfile*
221:[count]lpf[ile][!]	Same as ":cNfile" and ":cpfile", except the location
222			list for the current window is used instead of the
223			quickfix list.
224
225							*[_CTRL-L*
226[_CTRL-L		Mapped to |:lpfile|. |default-mappings|
227
228							*:crewind* *:cr*
229:cr[ewind][!] [nr]	Display error [nr].  If [nr] is omitted, the FIRST
230			error is displayed.  See |:cc|.
231
232							*[Q*
233[Q			Mapped to |:crewind|. |default-mappings|
234
235							*:lrewind* *:lr*
236:lr[ewind][!] [nr]	Same as ":crewind", except the location list for the
237			current window is used instead of the quickfix list.
238
239							*[L*
240[L			Mapped to |:lrewind|. |default-mappings|
241
242							*:cfirst* *:cfir*
243:cfir[st][!] [nr]	Same as ":crewind".
244
245							*:lfirst* *:lfir*
246:lfir[st][!] [nr]	Same as ":lrewind".
247
248							*:clast* *:cla*
249:cla[st][!] [nr]	Display error [nr].  If [nr] is omitted, the LAST
250			error is displayed.  See |:cc|.
251
252							*]Q*
253]Q			Mapped to |:clast|.
254
255							*:llast* *:lla*
256:lla[st][!] [nr]	Same as ":clast", except the location list for the
257			current window is used instead of the quickfix list.
258
259							*]L*
260]L			Mapped to |:llast|.
261
262							*:cq* *:cquit*
263:cq[uit][!]
264:{N}cq[uit][!]
265:cq[uit][!] {N}		Quit Vim with error code {N}.  {N} defaults to one.
266			Useful when Vim is called from another program:
267			e.g., a compiler will not compile the same file again,
268			`git commit` will abort the committing process, `fc`
269			(built-in for shells like bash and zsh) will not
270			execute the command, etc.
271			{N} can also be zero, in which case Vim exits
272			normally.
273			WARNING: This abandons changes in all files, like
274			|:qall|!.
275			The [!] does not change this.  Vim returns a non-zero
276			exit code, unless {N} is zero.
277
278							*:cf* *:cfi* *:cfile*
279:cf[ile][!] [errorfile]	Read the error file and jump to the first error.
280			This is done automatically when Vim is started with
281			the -q option.  You can use this command when you
282			keep Vim running while compiling.  If you give the
283			name of the errorfile, the 'errorfile' option will
284			be set to [errorfile].  See |:cc| for [!].
285			If the encoding of the error file differs from the
286			'encoding' option, you can use the 'makeencoding'
287			option to specify the encoding.
288
289							*:lf* *:lfi* *:lfile*
290:lf[ile][!] [errorfile]	Same as ":cfile", except the location list for the
291			current window is used instead of the quickfix list.
292			You can not use the -q command-line option to set
293			the location list.
294
295
296:cg[etfile] [errorfile]					*:cg* *:cgetfile*
297			Read the error file.  Just like ":cfile" but don't
298			jump to the first error.
299			If the encoding of the error file differs from the
300			'encoding' option, you can use the 'makeencoding'
301			option to specify the encoding.
302
303
304:lg[etfile] [errorfile]					*:lg* *:lge* *:lgetfile*
305			Same as ":cgetfile", except the location list for the
306			current window is used instead of the quickfix list.
307
308							*:caddf* *:caddfile*
309:caddf[ile] [errorfile]	Read the error file and add the errors from the
310			errorfile to the current quickfix list.  If a quickfix
311			list is not present, then a new list is created.
312			If the encoding of the error file differs from the
313			'encoding' option, you can use the 'makeencoding'
314			option to specify the encoding.
315
316							*:laddf* *:laddfile*
317:laddf[ile] [errorfile]	Same as ":caddfile", except the location list for the
318			current window is used instead of the quickfix list.
319
320The following commands read error messages from a buffer:
321`:cbuffer` creates a list and jumps to its first error, `:cgetbuffer` creates
322a list without jumping, and `:caddbuffer` adds entries to the current list
323without changing the cursor position.  The corresponding commands with an "l"
324prefix use the location list.
325
326						*:cb* *:cbuffer* *E681*
327:[range]cb[uffer][!] [bufnr]
328			Read the error list from the current buffer.
329			When [bufnr] is given it must be the number of a
330			loaded buffer.  That buffer will then be used instead
331			of the current buffer.
332			A range can be specified for the lines to be used, for
333			example `:10,20cbuffer`.  Otherwise all lines in the
334			buffer are used.
335			See |:cc| for [!].
336
337						*:lb* *:lbuffer*
338:[range]lb[uffer][!] [bufnr]
339			Same as ":cbuffer", except the location list for the
340			current window is used instead of the quickfix list.
341
342						*:cgetb* *:cgetbuffer*
343:[range]cgetb[uffer] [bufnr]
344			Read the error list from the current buffer.  Just
345			like ":cbuffer" but don't jump to the first error.
346
347						*:lgetb* *:lgetbuffer*
348:[range]lgetb[uffer] [bufnr]
349			Same as ":cgetbuffer", except the location list for
350			the current window is used instead of the quickfix
351			list.
352
353						*:cad* *:cadd* *:caddbuffer*
354:[range]cad[dbuffer] [bufnr]
355			Read the error list from the current buffer and add
356			the errors to the current quickfix list.  If a
357			quickfix list is not present, then a new list is
358			created.  Otherwise, same as ":cbuffer".
359
360							*:laddb* *:laddbuffer*
361:[range]laddb[uffer] [bufnr]
362			Same as ":caddbuffer", except the location list for
363			the current window is used instead of the quickfix
364			list.
365
366The following commands create or update a quickfix list from an expression:
367`:cexpr` creates a list and jumps to its first error, `:cgetexpr` creates a
368list without jumping, and `:caddexpr` adds entries to the current list without
369changing the cursor position.  The corresponding commands with an "l" prefix
370use the location list.
371
372							*:cex* *:cexpr* *E777*
373:cex[pr][!] {expr}	Create a quickfix list using the result of {expr} and
374			jump to the first error.
375			If {expr} is a String, then each newline terminated
376			line in the String is processed using the global value
377			of 'errorformat' and the result is added to the
378			quickfix list.
379			If {expr} is a List, then each String item in the list
380			is processed and added to the quickfix list.  Non
381			String items in the List are ignored.
382			See |:cc| for [!].
383			Examples: >
384				:cexpr system('grep -n xyz *')
385				:cexpr getline(1, '$')
386<
387							*:lex* *:lexpr*
388:lex[pr][!] {expr}	Same as |:cexpr|, except the location list for the
389			current window is used instead of the quickfix list.
390
391							*:cgete* *:cgetexpr*
392:cgete[xpr] {expr}	Create a quickfix list using the result of {expr}.
393			Just like |:cexpr|, but don't jump to the first error.
394
395							*:lgete* *:lgetexpr*
396:lgete[xpr] {expr}	Same as |:cgetexpr|, except the location list for the
397			current window is used instead of the quickfix list.
398
399							*:cadde* *:caddexpr*
400:cadde[xpr] {expr}	Evaluate {expr} and add the resulting lines to the
401			current quickfix list.  If a quickfix list is not
402			present, then a new list is created.  The current
403			cursor position will not be changed.  See |:cexpr| for
404			more information.
405			Example: >
406    :g/mypattern/caddexpr expand("%") .. ":" .. line(".") ..  ":" .. getline(".")
407<
408						*:lad* *:ladd* *:laddexpr*
409:lad[dexpr] {expr}	Same as ":caddexpr", except the location list for the
410			current window is used instead of the quickfix list.
411
412							*:cl* *:clist*
413:cl[ist] [from] [, [to]]
414			List all errors that are valid |quickfix-valid|.
415			If numbers [from] and/or [to] are given, the
416			respective range of errors is listed.  A negative
417			number counts from the last error backwards, -1 being
418			the last error.
419			The |:filter| command can be used to display only the
420			quickfix entries matching a supplied pattern.  The
421			pattern is matched against the filename, module name,
422			pattern and text of the entry.
423			For example, `:filter /\.c:/clist` lists only entries
424			whose displayed text contains `.c:`.  See |:filter|.
425
426:cl[ist] +{count}	List the current and next {count} valid errors.  This
427			is similar to ":clist from from+count", where "from"
428			is the current error position.
429
430:cl[ist]! [from] [, [to]]
431			List all errors.
432
433:cl[ist]! +{count}	List the current and next {count} error lines.  This
434			is useful to see unrecognized lines after the current
435			one.  For example, if ":clist" shows:
436	8384 testje.java:252: error: cannot find symbol ~
437			Then using ":cl! +3" shows the reason:
438	8384 testje.java:252: error: cannot find symbol ~
439	8385:   ZexitCode = Fmainx(); ~
440	8386:               ^ ~
441	8387:   symbol:   method Fmainx() ~
442
443:lli[st] [from] [, [to]]				*:lli* *:llist*
444			Same as ":clist", except the location list for the
445			current window is used instead of the quickfix list.
446
447:lli[st]! [from] [, [to]]
448			List all the entries in the location list for the
449			current window.
450
451If you insert or delete lines, mostly the correct error location is still
452found because hidden marks are used.  Sometimes, when the mark has been
453deleted for some reason, the message "line changed" is shown to warn you that
454the error location may not be correct.  If you quit Vim and start again the
455marks are lost and the error locations may not be correct anymore.
456
457Two autocommands are available for running commands before and after a
458quickfix command (':make', ':grep' and so on) is executed.  See
459|QuickFixCmdPre| and |QuickFixCmdPost| for details.
460
461						*QuickFixCmdPost-example*
462When 'encoding' differs from the locale, the error messages may have a
463different encoding from what Vim is using.  To convert the messages you can
464use this code: >
465	function QfMakeConv()
466	   let qflist = getqflist()
467	   for i in qflist
468	      let i.text = iconv(i.text, "cp936", "utf-8")
469	   endfor
470	   call setqflist(qflist)
471	endfunction
472
473	au QuickFixCmdPost make call QfMakeConv()
474Another option is using 'makeencoding'.
475
476							*quickfix-title*
477Every quickfix and location list has a title.  By default the title is set to
478the command that created the list.  The |getqflist()| and |getloclist()|
479functions can be used to get the title of a quickfix and a location list
480respectively.  The |setqflist()| and |setloclist()| functions can be used to
481modify the title of a quickfix and location list respectively.  Examples: >
482	call setqflist([], 'a', {'title' : 'Cmd output'})
483	echo getqflist({'title' : 1})
484	call setloclist(3, [], 'a', {'title' : 'Cmd output'})
485	echo getloclist(3, {'title' : 1})
486<
487							*quickfix-index*
488When you jump to a quickfix/location list entry using any of the quickfix
489commands (e.g. |:cc|, |:cnext|, |:cprev|, etc.), that entry becomes the
490currently selected entry.  The index of the currently selected entry in a
491quickfix/location list can be obtained using the getqflist()/getloclist()
492functions.  Examples: >
493	echo getqflist({'idx' : 0}).idx
494	echo getqflist({'id' : qfid, 'idx' : 0}).idx
495	echo getloclist(2, {'idx' : 0}).idx
496<
497For a new quickfix list, the first entry is selected and the index is 1.  Any
498entry in any quickfix/location list can be set as the currently selected entry
499using the setqflist() function.  Examples: >
500	call setqflist([], 'a', {'idx' : 12})
501	call setqflist([], 'a', {'id' : qfid, 'idx' : 7})
502	call setloclist(1, [], 'a', {'idx' : 7})
503<
504							*quickfix-size*
505You can get the number of entries (size) in a quickfix and a location list
506using the |getqflist()| and |getloclist()| functions respectively.  Examples: >
507	echo getqflist({'size' : 1})
508	echo getloclist(5, {'size' : 1})
509<
510							*quickfix-context*
511Any Vim type can be associated as a context with a quickfix or location list.
512The |setqflist()| and the |setloclist()| functions can be used to associate a
513context with a quickfix and a location list respectively.  The |getqflist()|
514and the |getloclist()| functions can be used to retrieve the context of a
515quickfix and a location list respectively.  This is useful for a Vim plugin
516dealing with multiple quickfix/location lists.
517Examples: >
518
519	let somectx = {'name' : 'Vim', 'type' : 'Editor'}
520	call setqflist([], 'a', {'context' : somectx})
521	echo getqflist({'context' : 1})
522
523	let newctx = ['red', 'green', 'blue']
524	call setloclist(2, [], 'a', {'id' : qfid, 'context' : newctx})
525	echo getloclist(2, {'id' : qfid, 'context' : 1})
526<
527							*quickfix-parse*
528You can parse a list of lines using 'errorformat' without creating or
529modifying a quickfix list using the |getqflist()| function.  Examples: >
530	echo getqflist({'lines' : ["F1:10:Line10", "F2:20:Line20"]})
531	echo getqflist({'lines' : systemlist('grep -Hn quickfix *')})
532This returns a dictionary where the "items" key contains the list of quickfix
533entries parsed from lines.  The following shows how to use a custom
534'errorformat' to parse the lines without modifying the 'errorformat' option: >
535	echo getqflist({'efm' : '%f#%l#%m', 'lines' : ['F1#10#Line']})
536<
537
538To execute a command for entries or files in a list, use:
539
540				 Quickfix list  Location list
541	Each entry		 :cdo		 :ldo
542	Each file		 :cfdo		 :lfdo
543
544Use `:cdo` when a command should run for every valid entry, for example
545`:cdo s/old/new/g` to change each matching line.  Use `:cfdo` when it should
546run once for each file, for example `:cfdo update` to write each affected file
547once.  Add the "l" prefix to use the location list instead.
548
549The commands below describe these differences in more detail.
550
551EXECUTE A COMMAND IN ALL THE BUFFERS IN QUICKFIX OR LOCATION LIST:
552							*:cdo*
553:cdo[!] {cmd}		Execute {cmd} in each valid entry in the quickfix
554			list.  It works like doing this: >
555				:cfirst
556				:{cmd}
557				:cnext
558				:{cmd}
559				etc.
560<			When the current file can't be |abandon|ed and the [!]
561			is not present, the command fails.
562			When going to the next entry fails execution stops.
563			The last buffer (or where an error occurred) becomes
564			the current buffer.
565			{cmd} can contain '|' to concatenate several commands.
566
567			Only valid entries in the quickfix list are used.
568			A range can be used to select entries, e.g.: >
569				:10,$cdo cmd
570<			To skip entries 1 to 9.
571
572			Note: While this command is executing, the Syntax
573			autocommand event is disabled by adding it to
574			'eventignore'.  This considerably speeds up editing
575			each buffer.
576			Also see |:bufdo|, |:tabdo|, |:argdo|, |:windo|,
577			|:ldo|, |:cfdo| and |:lfdo|.
578
579							*:cfd* *:cfdo*
580:cfd[o][!] {cmd}	Execute {cmd} in each file in the quickfix list.
581			It works like doing this: >
582				:cfirst
583				:{cmd}
584				:cnfile
585				:{cmd}
586				etc.
587<			Otherwise it works the same as `:cdo`.
588
589							*:ld* *:ldo*
590:ld[o][!] {cmd}		Execute {cmd} in each valid entry in the location list
591			for the current window.
592			It works like doing this: >
593				:lfirst
594				:{cmd}
595				:lnext
596				:{cmd}
597				etc.
598<			Only valid entries in the location list are used.
599			Otherwise it works the same as `:cdo`.
600
601							*:lfd* *:lfdo*
602:lfd[o][!] {cmd}	Execute {cmd} in each file in the location list for
603			the current window.
604			It works like doing this: >
605				:lfirst
606				:{cmd}
607				:lnfile
608				:{cmd}
609				etc.
610<			Otherwise it works the same as `:ldo`.
611
612FILTERING A QUICKFIX OR LOCATION LIST:
613		    *cfilter-plugin* *:Cfilter* *:Lfilter* *package-cfilter*
614If you have too many entries in a quickfix list, you can use the cfilter
615plugin to reduce the number of entries.  Load the plugin with: >vim
616
617    packadd cfilter
618
619Then you can use the following commands to filter a quickfix/location list: >
620
621    :Cfilter[!] /{pat}/
622    :Lfilter[!] /{pat}/
623
624The |:Cfilter| command creates a new quickfix list from the entries matching
625{pat} in the current quickfix list.  {pat} is a Vim |regular-expression|
626pattern.  Both the file name and the text of the entries are matched against
627{pat}.  If the optional ! is supplied, then the entries not matching {pat} are
628used.  The pattern can be optionally enclosed using one of the following
629characters: ', ", /.  If the pattern is empty, then the last used search
630pattern is used.
631
632The |:Lfilter| command does the same as |:Cfilter| but operates on the current
633location list.
634
635The current quickfix/location list is not modified by these commands, so you
636can go back to the unfiltered list using the |:colder|/|:lolder| command.
637
638=============================================================================
6392. The error window					*quickfix-window*
640
641					    *:cope* *:copen* *w:quickfix_title*
642:cope[n] [height]	Open a window to show the current list of errors.
643
644			When [height] is given, the window becomes that high
645			(if there is room).  When [height] is omitted the
646			window is made ten lines high.
647
648			If there already is a quickfix window, it will be made
649			the current window.  It is not possible to open a
650			second quickfix window.  If [height] is given the
651			existing window will be resized to it.
652
653							*quickfix-buffer*
654			The window will contain a special buffer, with
655			'buftype' equal to "quickfix".  Don't change this!
656			The window will have the w:quickfix_title variable set
657			which will indicate the command that produced the
658			quickfix list.  This can be used to compose a custom
659			status line if the value of 'statusline' is adjusted
660			properly.  Whenever this buffer is modified by a
661			quickfix command or function, the |b:changedtick|
662			variable is incremented.  You can get the number of
663			this buffer using the getqflist() and getloclist()
664			functions by passing the "qfbufnr" item.  For a
665			location list, this buffer is wiped out when the
666			location list is removed.
667
668							*:lop* *:lopen*
669:lop[en] [height]	Open a window to show the location list for the
670			current window.  Works only when the location list for
671			the current window is present.  You can have more than
672			one location window opened at a time.  Otherwise, it
673			acts the same as ":copen".
674
675							*:ccl* *:cclose*
676:ccl[ose]		Close the quickfix window.
677
678							*:lcl* *:lclose*
679:lcl[ose]		Close the window showing the location list for the
680			current window.
681
682							*:cw* *:cwindow*
683:cw[indow] [height]	Open the quickfix window when there are recognized
684			errors.  If the window is already open and there are
685			no recognized errors, close the window.
686
687			When opening the window and [height] is given, the
688			window becomes that high (if there is room).  When
689			[height] is omitted the window is made ten lines high.
690
691							*:lw* *:lwindow*
692:lw[indow] [height]	Same as ":cwindow", except use the window showing the
693			location list for the current window.
694
695							*:cbo* *:cbottom*
696:cbo[ttom]		Put the cursor in the last line of the quickfix window
697			and scroll to make it visible.  This is useful for
698			when errors are added by an asynchronous callback.
699			Only call it once in a while if there are many
700			updates to avoid a lot of redrawing.
701
702							*:lbo* *:lbottom*
703:lbo[ttom]		Same as ":cbottom", except use the window showing the
704			location list for the current window.
705
706Normally the quickfix window is at the bottom of the screen.
707You can move the window around with |window-moving| commands.
708For example, to move it to the top: CTRL-W K
709The 'winfixheight' option will be set, which means that the window will mostly
710keep its height, ignoring 'winheight' and 'equalalways'.  You can change the
711height manually (e.g., by dragging the status line above it with the mouse).
712
713In the quickfix window, each line is one error.  The line number is equal to
714the error number.  The current entry is highlighted with the QuickFixLine
715highlighting.  You can change it to your liking, e.g.: >
716	:hi QuickFixLine ctermbg=Yellow guibg=Yellow
717
718You can use ":.cc" to jump to the error under the cursor.
719Hitting the <Enter> key or double-clicking the mouse on a line has the same
720effect.  The file containing the error is opened in the window above the
721quickfix window.  If there already is a window for that file, it is used
722instead.  If the buffer in the used window has changed, and the error is in
723another file, jumping to the error will fail.  You will first have to make
724sure the window contains a buffer which can be abandoned.
725
726When you select a file from the quickfix window, Vim first reuses a window
727that already displays the file.  Otherwise it uses a suitable window in the
728current tab page, or opens a new one.  The detailed selection rules are:
729
7301. If a window displaying the selected file is present in the current tabpage
731   (starting with the window before the quickfix window), then that window is
732   used.
7332. If the above step fails and if 'switchbuf' contains "usetab" and a window
734   displaying the selected file is present in any one of the tabpages
735   (starting with the first tabpage) then that window is used.
7363. If the above step fails then a window in the current tabpage displaying a
737   buffer with 'buftype' not set (starting with the window before the quickfix
738   window) is used.
7394. If the above step fails and if 'switchbuf' contains "uselast", then the
740   previously accessed window is used.
7415. If the above step fails then the window before the quickfix window is used.
742   If there is no previous window, then the window after the quickfix window
743   is used.
7446. If the above step fails, then a new horizontally split window above the
745   quickfix window is used.
746
747						*quickfix-winfixbuf*
748When 'winfixbuf' is set for the window that would be used to display the
749error, jumping to an error in another buffer is not possible in that window.
750For a quickfix list Vim then looks for another suitable window, using the
751previously accessed window if it does not have 'winfixbuf' set, and otherwise
752splits a new window.  For a location list this fails with |E1513|, because a
753location list is tied to its window and cannot move to or split off another
754one.  Using [!] skips these checks.
755
756					*CTRL-W_<Enter>* *CTRL-W_<CR>*
757You can use CTRL-W <Enter> to open a new window and jump to the error there.
758
759When the quickfix window has been filled, two autocommand events are
760triggered.  First the 'filetype' option is set to "qf", which triggers the
761FileType event (also see |qf.vim|).  Then the BufReadPost event is triggered,
762using "quickfix" for the buffer name.  This can be used to perform some action
763on the listed errors.  Example: >
764	au BufReadPost quickfix  setlocal modifiable
765		\ | silent exe 'g/^/s//\=line(".") .. " "/'
766		\ | setlocal nomodifiable
767This prepends the line number to each line.  Note the use of "\=" in the
768substitute string of the ":s" command, which is used to evaluate an
769expression.
770The BufWinEnter event is also triggered, again using "quickfix" for the buffer
771name.
772
773Note: When adding to an existing quickfix list the autocommand are not
774triggered.
775
776Note: Making changes in the quickfix window has no effect on the list of
777errors.  'modifiable' is off to avoid making changes.  If you delete or insert
778lines anyway, the relation between the text and the error number is messed up.
779If you really want to do this, you could write the contents of the quickfix
780window to a file and use ":cfile" to have it parsed and used as the new error
781list.
782
783						*location-list-window*
784The location list window displays the entries in a location list.  When you
785open a location list window, it is created below the current window and
786displays the location list for the current window.  The location list window
787is similar to the quickfix window, except that you can have more than one
788location list window open at a time.  When you use a location list command in
789this window, the displayed location list is used.
790
791When you select a file from the location list window, Vim first uses the
792window associated with that location list, when possible.  Otherwise it
793reuses a suitable window or opens a new one.  The detailed selection rules
794are:
795
7961. If a non-quickfix window associated with the location list is present in
797   the current tabpage, then that window is used.
7982. If the above step fails and if the file is already opened in another window
799   in the current tabpage, then that window is used.
8003. If the above step fails and 'switchbuf' contains "usetab" and if the file
801   is opened in a window in any one of the tabpages, then that window is used.
8024. If the above step fails then a window in the current tabpage showing a
803   buffer with 'buftype' not set is used.
8045. If the above step fails, then the file is edited in a new window.
805
806In all of the above cases, if the location list for the selected window is not
807yet set, then it is set to the location list displayed in the location list
808window.
809
810							*quickfix-window-ID*
811You can use the |getqflist()| and |getloclist()| functions to obtain the
812window ID of the quickfix window and location list window respectively (if
813present).  Examples: >
814	echo getqflist({'winid' : 1}).winid
815	echo getloclist(2, {'winid' : 1}).winid
816<
817							*getqflist-examples*
818The |getqflist()| and |getloclist()| functions can be used to get the various
819attributes of a quickfix and location list respectively.  Some examples for
820using these functions are below:
821>
822    " get the title of the current quickfix list
823    :echo getqflist({'title' : 0}).title
824
825    " get the identifier of the current quickfix list
826    :let qfid = getqflist({'id' : 0}).id
827
828    " get the identifier of the fourth quickfix list in the stack
829    :let qfid = getqflist({'nr' : 4, 'id' : 0}).id
830
831    " check whether a quickfix list with a specific identifier exists
832    :if getqflist({'id' : qfid}).id == qfid
833
834    " get the index of the current quickfix list in the stack
835    :let qfnum = getqflist({'nr' : 0}).nr
836
837    " get the items of a quickfix list specified by an identifier
838    :echo getqflist({'id' : qfid, 'items' : 0}).items
839
840    " get the number of entries in a quickfix list specified by an id
841    :echo getqflist({'id' : qfid, 'size' : 0}).size
842
843    " get the context of the third quickfix list in the stack
844    :echo getqflist({'nr' : 3, 'context' : 0}).context
845
846    " get the number of quickfix lists in the stack
847    :echo getqflist({'nr' : '$'}).nr
848
849    " get the number of times the current quickfix list is changed
850    :echo getqflist({'changedtick' : 0}).changedtick
851
852    " get the current entry in a quickfix list specified by an identifier
853    :echo getqflist({'id' : qfid, 'idx' : 0}).idx
854
855    " get all the quickfix list attributes using an identifier
856    :echo getqflist({'id' : qfid, 'all' : 0})
857
858    " parse text from a List of lines and return a quickfix list
859    :let myList = ["a.java:10:L10", "b.java:20:L20"]
860    :echo getqflist({'lines' : myList}).items
861
862    " parse text using a custom 'efm' and return a quickfix list
863    :echo getqflist({'lines' : ['a.c#10#Line 10'], 'efm':'%f#%l#%m'}).items
864
865    " get the quickfix list window id
866    :echo getqflist({'winid' : 0}).winid
867
868    " get the quickfix list window buffer number
869    :echo getqflist({'qfbufnr' : 0}).qfbufnr
870
871    " get the context of the current location list
872    :echo getloclist(0, {'context' : 0}).context
873
874    " get the location list window id of the third window
875    :echo getloclist(3, {'winid' : 0}).winid
876
877    " get the location list window buffer number of the third window
878    :echo getloclist(3, {'qfbufnr' : 0}).qfbufnr
879
880    " get the file window id of a location list window (winnr: 4)
881    :echo getloclist(4, {'filewinid' : 0}).filewinid
882<
883							*setqflist-examples*
884The |setqflist()| and |setloclist()| functions can be used to set the various
885attributes of a quickfix and location list respectively.  Some examples for
886using these functions are below:
887>
888    " create an empty quickfix list with a title and a context
889    :let t = 'Search results'
890    :let c = {'cmd' : 'grep'}
891    :call setqflist([], ' ', {'title' : t, 'context' : c})
892
893    " set the title of the current quickfix list
894    :call setqflist([], 'a', {'title' : 'Mytitle'})
895
896    " change the current entry in the list specified by an identifier
897    :call setqflist([], 'a', {'id' : qfid, 'idx' : 10})
898
899    " set the context of a quickfix list specified by an identifier
900    :call setqflist([], 'a', {'id' : qfid, 'context' : {'val' : 100}})
901
902    " create a new quickfix list from a command output
903    :call setqflist([], ' ', {'lines' : systemlist('grep -Hn main *.c')})
904
905    " parse text using a custom efm and add to a particular quickfix list
906    :call setqflist([], 'a', {'id' : qfid,
907		\ 'lines' : ["a.c#10#L10", "b.c#20#L20"], 'efm':'%f#%l#%m'})
908
909    " add items to the quickfix list specified by an identifier
910    :let newItems = [{'filename' : 'a.txt', 'lnum' : 10, 'text' : "Apple"},
911		    \ {'filename' : 'b.txt', 'lnum' : 20, 'text' : "Orange"}]
912    :call setqflist([], 'a', {'id' : qfid, 'items' : newItems})
913
914    " empty a quickfix list specified by an identifier
915    :call setqflist([], 'r', {'id' : qfid, 'items' : []})
916
917    " free all the quickfix lists in the stack
918    :call setqflist([], 'f')
919
920    " set the title of the fourth quickfix list
921    :call setqflist([], 'a', {'nr' : 4, 'title' : 'SomeTitle'})
922
923    " create a new quickfix list at the end of the stack
924    :call setqflist([], ' ', {'nr' : '$',
925			\ 'lines' : systemlist('grep -Hn class *.java')})
926
927    " create a new location list from a command output
928    :call setloclist(0, [], ' ', {'lines' : systemlist('grep -Hn main *.c')})
929
930    " replace the location list entries for the third window
931    :call setloclist(3, [], 'r', {'items' : newItems})
932<
933=============================================================================
9343. Using more than one list of errors			*quickfix-error-lists*
935
936So far it has been assumed that there is only one list of errors.  Actually
937there can be multiple used lists that are remembered; see 'chistory' and
938'lhistory'.
939When starting a new list, the previous ones are automatically kept.  Two
940commands can be used to access older error lists.  They set one of the
941existing error lists as the current one.
942
943						*:colder* *:col* *E380*
944:col[der] [count]	Go to older error list.  When [count] is given, do
945			this [count] times.  When already at the oldest error
946			list, an error message is given.
947
948						*:lolder* *:lol*
949:lol[der] [count]	Same as `:colder`, except use the location list for
950			the current window instead of the quickfix list.
951
952						*:cnewer* *:cnew* *E381*
953:cnew[er] [count]	Go to newer error list.  When [count] is given, do
954			this [count] times.  When already at the newest error
955			list, an error message is given.
956
957						*:lnewer* *:lnew*
958:lnew[er] [count]	Same as `:cnewer`, except use the location list for
959			the current window instead of the quickfix list.
960
961						*:chistory* *:chi*
962:[count]chi[story]	Show the list of error lists.  The current list is
963			marked with ">".  The output looks like: >
964			  error list 1 of 3; 43 errors   :make
965			> error list 2 of 3; 0 errors    :helpgrep tag
966			  error list 3 of 3; 15 errors   :grep ex_help *.c
967<
968			When [count] is given, then the count'th quickfix
969			list is made the current list.  Example: >
970				" Make the 4th quickfix list current
971				:4chistory
972<
973						*:lhistory* *:lhi*
974:[count]lhi[story]	Show the list of location lists, otherwise like
975			`:chistory`.
976
977When adding a new error list, it becomes the current list.
978
979When ":colder" has been used and ":make" or ":grep" is used to add a new error
980list, one newer list is overwritten.  This is especially useful if you are
981browsing with ":grep" |grep|.  If you want to keep the more recent error
982lists, use ":cnewer 99" first.
983
984To get the number of lists in the quickfix and location list stack, you can
985use the |getqflist()| and |getloclist()| functions respectively with the list
986number set to the special value '$'.  Examples: >
987	echo getqflist({'nr' : '$'}).nr
988	echo getloclist(3, {'nr' : '$'}).nr
989To get the number of the current list in the stack: >
990	echo getqflist({'nr' : 0}).nr
991<
992=============================================================================
9934. Using :make						*:make_makeprg*
994
995							*:mak* *:make*
996:mak[e][!] [arguments]	1. All relevant |QuickFixCmdPre| autocommands are
997			   executed.
998			2. If the 'autowrite' option is on, write any changed
999			   buffers
1000			3. An errorfile name is made from 'makeef'.  If
1001			   'makeef' doesn't contain "##", and a file with this
1002			   name already exists, it is deleted.
1003			4. The program given with the 'makeprg' option is
1004			   started (default "make") with the optional
1005			   [arguments] and the output is saved in the
1006			   errorfile (for Unix it is also echoed on the
1007			   screen).
1008			5. The errorfile is read using 'errorformat'.
1009			6. All relevant |QuickFixCmdPost| autocommands are
1010			   executed.  See example below.
1011			7. If [!] is not given the first error is jumped to.
1012			8. The errorfile is deleted.
1013			9. You can now move through the errors with commands
1014			   like |:cnext| and |:cprevious|, see above.
1015			This command does not accept a comment, any "
1016			characters are considered part of the arguments.
1017			If the encoding of the program output differs from the
1018			'encoding' option, you can use the 'makeencoding'
1019			option to specify the encoding.
1020
1021							*:lmak* *:lmake*
1022:lmak[e][!] [arguments]
1023			Same as ":make", except the location list for the
1024			current window is used instead of the quickfix list.
1025
1026In short, `:make` runs 'makeprg', reads its output using 'errorformat',
1027optionally jumps to the first recognized error, and then removes the temporary
1028error file used by the normal `:make` workflow.  If 'shellpipe' is empty, or
1029if the program manages its own output file, this cleanup does not apply to
1030that program's file.  Use |:cnext| and related commands to move through the
1031resulting list.
1032
1033The ":make" command executes the command given with the 'makeprg' option.
1034This is done by passing the command to the shell given with the 'shell'
1035option.  This works almost like typing
1036
1037	":!{makeprg} [arguments] {shellpipe} {errorfile}".
1038
1039{makeprg} is the string given with the 'makeprg' option.  Any command can be
1040used, not just "make".  Characters '%' and '#' are expanded as usual on a
1041command-line.  You can use "%<" to insert the current file name without
1042extension, or "#<" to insert the alternate file name without extension, for
1043example: >
1044   :set makeprg=make\ #<.o
1045
1046[arguments] is anything that is typed after ":make".
1047{shellpipe} is the 'shellpipe' option.
1048{errorfile} is the 'makeef' option, with ## replaced to make it unique.
1049
1050The placeholder "$*" can be used for the argument list in {makeprg} if the
1051command needs some additional characters after its arguments.  The $* is
1052replaced then by all arguments.  Example: >
1053   :set makeprg=latex\ \\\\nonstopmode\ \\\\input\\{$*}
1054or simpler >
1055   :let &mp = 'latex \\nonstopmode \\input\{$*}'
1056"$*" can be given multiple times, for example: >
1057   :set makeprg=gcc\ -o\ $*\ $*
1058
1059The 'shellpipe' option defaults to "2>&1| tee" for Win32.
1060This means that the output of the compiler is saved in a file and not shown on
1061the screen directly.  For Unix "| tee" is used.  The compiler output is shown
1062on the screen and saved in a file the same time.  Depending on the shell used
1063"|& tee" or "2>&1| tee" is the default, so stderr output will be included.
1064
1065If 'shellpipe' is empty, the {errorfile} part will be omitted.  This is useful
1066for compilers that write to an errorfile themselves.
1067
1068
1069Using QuickFixCmdPost to fix the encoding ~
1070
1071It may be that 'encoding' is set to an encoding that differs from the messages
1072your build program produces.  This example shows how to fix this after Vim has
1073read the error messages: >
1074
1075	function QfMakeConv()
1076	   let qflist = getqflist()
1077	   for i in qflist
1078	      let i.text = iconv(i.text, "cp936", "utf-8")
1079	   endfor
1080	   call setqflist(qflist)
1081	endfunction
1082
1083	au QuickFixCmdPost make call QfMakeConv()
1084
1085(Example by Faque Cheng)
1086Another option is using 'makeencoding'.
1087
1088==============================================================================
10895. Using :vimgrep and :grep				*grep* *lid*
1090
1091Vim has two ways to find matches for a pattern: internal and external.  The
1092advantage of the internal grep is that it works on all systems and uses the
1093powerful Vim search patterns.  An external grep program can be used when the
1094Vim grep does not do what you want.
1095
1096The internal method will be slower, because files are read into memory.  For
1097large projects, consider using |:grep| with an external search program.  The
1098advantages of the internal method are:
1099- Line separators and encoding are automatically recognized, as if a file is
1100  being edited.
1101- Uses Vim search patterns.  Multi-line patterns can be used.
1102- When plugins are enabled: compressed and remote files can be searched.
1103	|gzip| |netrw|
1104
1105To be able to do this Vim loads each file as if it is being edited.  When
1106there is no match in the file the associated buffer is wiped out again.  The
1107'hidden' option is ignored here to avoid running out of memory or file
1108descriptors when searching many files.  However, when the |:hide| command
1109modifier is used the buffers are kept loaded.  This makes following searches
1110in the same files a lot faster.
1111
1112Note that |:copen| (or |:lopen| for |:lgrep|) may be used to open a buffer
1113containing the search results in linked form.  The |:silent| command may be
1114used to suppress the default full screen grep output.  The ":grep!" form of
1115the |:grep| command doesn't jump to the first match automatically.  These
1116commands can be combined to create a NewGrep command: >
1117
1118        command! -nargs=+ NewGrep execute 'silent grep! <args>' | copen 42
1119
1120
11215.1 Using Vim's internal grep
1122
1123					*:vim* *:vimgrep* *E682* *E683*
1124:vim[grep][!] /{pattern}/[g][j][f] {file} ...
1125			Search for {pattern} in the files {file} ... and set
1126			the error list to the matches.  Files matching
1127			'wildignore' are ignored; files in 'suffixes' are
1128			searched last.
1129
1130			{pattern} is a Vim search pattern.  Instead of
1131			enclosing it in / any non-ID character (see
1132			'isident') can be used, so long as it does not appear
1133			in {pattern}.
1134			'ignorecase' applies.  To overrule it put |/\c| in the
1135			pattern to ignore case or |/\C| to match case.
1136			'smartcase' is not used.
1137			If {pattern} is empty (e.g. // is specified), the last
1138			used search pattern is used. |last-pattern|
1139
1140			Flags:
1141			'g'  Without the 'g' flag each line is added only
1142			     once.  With 'g' every match is added.
1143
1144			'j'  Without the 'j' flag Vim jumps to the first
1145			     match.  With 'j' only the quickfix list is
1146			     updated.  With the [!] any changes in the current
1147			     buffer are abandoned.
1148
1149			'f'  When the 'f' flag is specified, fuzzy string
1150			     matching is used to find matching lines.  The
1151			     characters in {pattern} must appear in order, but
1152			     need not be next to each other.  In this case,
1153			     {pattern} is treated as a literal string instead
1154			     of a regular expression.  See |fuzzy-matching|
1155			     for more information about fuzzy matching
1156			     strings.
1157
1158			|QuickFixCmdPre| and |QuickFixCmdPost| are triggered.
1159			A file that is opened for matching may use a buffer
1160			number, but it is reused if possible to avoid
1161			consuming buffer numbers.
1162
1163:{count}vim[grep] ...
1164			When a number is put before the command this is used
1165			as the maximum number of matches to find.  Use
1166			":1vimgrep pattern file" to find only the first.
1167			Useful if you only want to check if there is a match
1168			and quit quickly when it's found.
1169
1170			Every second or so the searched file name is displayed
1171			to give you an idea of the progress made.
1172			Examples: >
1173				:vimgrep /an error/ *.c
1174				:vimgrep /\<FileName\>/ *.h include/*
1175				:vimgrep /myfunc/ **/*.c
1176<			For the use of "**" see |starstar-wildcard|.
1177
1178:vim[grep][!] {pattern} {file} ...
1179			Like above, but instead of enclosing the pattern in a
1180			non-ID character use a white space separated pattern.
1181			The pattern must start with an ID character.
1182			Example: >
1183				:vimgrep Error *.c
1184<
1185							*:lv* *:lvimgrep*
1186:lv[imgrep][!] /{pattern}/[g][j][f] {file} ...
1187:lv[imgrep][!] {pattern} {file} ...
1188			Same as ":vimgrep", except the location list for the
1189			current window is used instead of the quickfix list.
1190
1191						*:vimgrepa* *:vimgrepadd*
1192:vimgrepa[dd][!] /{pattern}/[g][j][f] {file} ...
1193:vimgrepa[dd][!] {pattern} {file} ...
1194			Just like ":vimgrep", but instead of making a new list
1195			of errors the matches are appended to the current
1196			list.
1197
1198						*:lvimgrepa* *:lvimgrepadd*
1199:lvimgrepa[dd][!] /{pattern}/[g][j][f] {file} ...
1200:lvimgrepa[dd][!] {pattern} {file} ...
1201			Same as ":vimgrepadd", except the location list for
1202			the current window is used instead of the quickfix
1203			list.
1204
12055.2 External grep
1206
1207Vim can interface with "grep" and grep-like programs (such as the GNU
1208id-utils) in a similar way to its compiler integration (see |:make| above).
1209
1210[Unix trivia: The name for the Unix "grep" command comes from ":g/re/p", where
1211"re" stands for Regular Expression.]
1212
1213							    *:gr* *:grep*
1214:gr[ep][!] [arguments]	Just like ":make", but use 'grepprg' instead of
1215			'makeprg' and 'grepformat' instead of 'errorformat'.
1216			When 'grepprg' is "internal" this works like
1217			|:vimgrep|.  Note that the pattern needs to be
1218			enclosed in separator characters then.
1219			If the encoding of the program output differs from the
1220			'encoding' option, you can use the 'makeencoding'
1221			option to specify the encoding.
1222
1223							    *:lgr* *:lgrep*
1224:lgr[ep][!] [arguments]	Same as ":grep", except the location list for the
1225			current window is used instead of the quickfix list.
1226
1227							*:grepa* *:grepadd*
1228:grepa[dd][!] [arguments]
1229			Just like ":grep", but instead of making a new list of
1230			errors the matches are appended to the current list.
1231			Example: >
1232				:call setqflist([])
1233				:bufdo grepadd! something %
1234<			The first command makes a new error list which is
1235			empty.  The second command executes "grepadd" for each
1236			listed buffer.  Note the use of ! to avoid that
1237			":grepadd" jumps to the first error, which is not
1238			allowed with |:bufdo|.
1239			An example that uses the argument list and avoids
1240			errors for files without matches: >
1241				:silent argdo try
1242				  \ | grepadd! something %
1243				  \ | catch /E480:/
1244				  \ | endtry"
1245<
1246			If the encoding of the program output differs from the
1247			'encoding' option, you can use the 'makeencoding'
1248			option to specify the encoding.
1249
1250							*:lgrepa* *:lgrepadd*
1251:lgrepa[dd][!] [arguments]
1252			Same as ":grepadd", except the location list for the
1253			current window is used instead of the quickfix list.
1254
12555.3 Setting up external grep
1256
1257If you have a standard "grep" program installed, the :grep command may work
1258well with the defaults.  The syntax is very similar to the standard command: >
1259
1260	:grep foo *.c
1261
1262Will search all files with the .c extension for the substring "foo".  The
1263arguments to :grep are passed straight to the "grep" program, so you can use
1264whatever options your "grep" supports.
1265
1266By default, :grep invokes grep with the -n option (show file and line
1267numbers).  You can change this with the 'grepprg' option.  You will need to
1268set 'grepprg' if:
1269
1270a)	You are using a program that isn't called "grep"
1271b)	You have to call grep with a full path
1272c)	You want to pass other options automatically (e.g. case insensitive
1273	search.)
1274
1275Once "grep" has executed, Vim parses the results using the 'grepformat'
1276option.  This option works in the same way as the 'errorformat' option - see
1277that for details.  You may need to change 'grepformat' from the default if
1278your grep outputs in a non-standard format, or you are using some other
1279program with a special format.
1280
1281Once the results are parsed, Vim loads the first file containing a match and
1282jumps to the appropriate line, in the same way that it jumps to a compiler
1283error in |quickfix| mode.  You can then use the |:cnext|, |:clist|, etc.
1284commands to see the other matches.
1285
1286
12875.4 Using :grep with id-utils
1288
1289You can set up :grep to work with the GNU id-utils like this: >
1290
1291	:set grepprg=lid\ -Rgrep\ -s
1292	:set grepformat=%f:%l:%m
1293
1294then >
1295	:grep (regexp)
1296
1297works just as you'd expect.
1298(provided you remembered to mkid first :)
1299
1300
13015.5 Browsing source code with :vimgrep or :grep
1302
1303Using the stack of error lists that Vim keeps, you can browse your files to
1304look for functions and the functions they call.  For example, suppose that you
1305have to add an argument to the read_file() function.  You enter this command: >
1306
1307	:vimgrep /\<read_file\>/ *.c
1308
1309You use ":cn" to go along the list of matches and add the argument.  At one
1310place you have to get the new argument from a higher level function msg(), and
1311need to change that one too.  Thus you use: >
1312
1313	:vimgrep /\<msg\>/ *.c
1314
1315While changing the msg() functions, you find another function that needs to
1316get the argument from a higher level.  You can again use ":vimgrep" to find
1317these functions.  Once you are finished with one function, you can use >
1318
1319	:colder
1320
1321to go back to the previous one.
1322
1323This works like browsing a tree: ":vimgrep" goes one level deeper, creating a
1324list of branches.  ":colder" goes back to the previous level.  You can mix
1325this use of ":vimgrep" and "colder" to browse all the locations in a tree-like
1326way.  If you do this consistently, you will find all locations without the
1327need to write down a "todo" list.
1328
1329=============================================================================
13306. Selecting a compiler					*compiler-select*
1331
1332						*:comp* *:compiler* *E666*
1333:comp[iler][!] {name}		Set options to work with compiler {name}.
1334				Without the "!" options are set for the
1335				current buffer.  With "!" global options are
1336				set.
1337				If you use ":compiler foo" in "file.foo" and
1338				then ":compiler! bar" in another buffer, Vim
1339				will keep on using "foo" in "file.foo".
1340
1341
1342The Vim plugins in the "compiler" directory will set options to use the
1343selected compiler.  For `:compiler` local options are set, for `:compiler!`
1344global options.
1345
1346In normal use, select a compiler with `:compiler {name}` and then run |:make|.
1347The compiler plugin usually sets 'makeprg' and 'errorformat' so Vim can run
1348the compiler and read its messages.  The descriptions below document options
1349for particular compiler plugins.
1350
1351The values set by a compiler plugin can be changed afterwards with |:set| or
1352|:setlocal|.  `:compiler {name}` sets options for the current buffer, while
1353`:compiler! {name}` sets global options; a buffer-local value takes precedence
1354over a global value.
1355
1356							*current_compiler*
1357To support older Vim versions, the plugins always use "current_compiler" and
1358not "b:current_compiler".  What the command actually does is the following:
1359
1360- Delete the "current_compiler" and "b:current_compiler" variables.
1361- Define the "CompilerSet" user command.  With "!" it does ":set", without "!"
1362  it does ":setlocal".
1363- Execute ":runtime! compiler/{name}.{vim,lua}".  The plugins are expected to
1364  set options with "CompilerSet" and set the "current_compiler" variable to the
1365  name of the compiler.
1366- Delete the "CompilerSet" user command.
1367- Set "b:current_compiler" to the value of "current_compiler".
1368- Without "!" the old value of "current_compiler" is restored.
1369
1370
1371For writing a compiler plugin, see |write-compiler-plugin|.
1372
1373Use the |compiler-make| plugin to undo the effect of a compiler plugin.
1374
1375BIOME				      *compiler-biome* *quickfix-biome*
1376
1377Biome check lints JavaScript, TypeScript, JSX, TSX, JSON, JSONC, HTML, Vue,
1378Svelte, Astro, CSS, GraphQL and GritQL files.
1379
1380Commonly used compiler options can be added to 'makeprg' by setting the
1381b/g:biome_makeprg_params variable.  For example (global default is ""): >
1382
1383  let b:biome_makeprg_params = "--diagnostic-level=error --staged"
1384
1385
1386CPPCHECK			*quickfix-cppcheck* *compiler-cppcheck*
1387
1388Use g/b:`c_cppcheck_params` to set cppcheck parameters.  The global
1389settings by default include
1390
1391- `--verbose`: Enables verbose output.
1392- `--force`: Forces checking of all configurations.
1393- `--inline-suppr`: Allows inline suppressions.
1394- `--enable=...`: Enables specific checks like warnings, style, performance,
1395  portability, information, and missing includes.
1396- `-j`: Utilizes multiple processors if available, determined by the
1397  `getconf` command if available (requires omitting the unusedFunction check)
1398
1399For C++ files (`filetype == 'cpp'`), the `--language=c++` option is added to
1400ensure Cppcheck treats the file as C++.
1401
1402If compile_commands.json is present in the current directory, it is added as a
1403`--project` parameter to the command line.  Otherwise, by default the
1404directories in &path are passed as include directories.  These can be set by
1405g/b:`c_cppcheck_includes` as a list of `-I` flags.  Tim Pope's vim-apathy
1406plug-in [0] can expand &path.  To also append the folders in a git repo use >
1407
1408  let &l:path = join(systemlist('git ls-tree -d --name-only -r HEAD'), ',')
1409
1410[0] https://github.com/tpope/vim-apathy
1411
1412DOTNET							*compiler-dotnet*
1413
1414The .NET CLI compiler outputs both errors and warnings by default.  The output
1415may be limited to include only errors, by setting the g:dotnet_errors_only
1416variable to |v:true|.
1417
1418The associated project name is included in each error and warning.  To
1419suppress the project name, set the g:dotnet_show_project_file variable to
1420|v:false|.
1421
1422Example: limit output to only display errors, and suppress the project name: >
1423	let dotnet_errors_only = v:true
1424	let dotnet_show_project_file = v:false
1425	compiler dotnet
1426<
1427GCC					*quickfix-gcc*	*compiler-gcc*
1428
1429There's one variable you can set for the GCC compiler:
1430
1431g:compiler_gcc_ignore_unmatched_lines
1432				Ignore lines that don't match any patterns
1433				defined for GCC.  Useful if output from
1434				commands run from make are generating false
1435				positives.
1436
1437JAVAC							*compiler-javac*
1438
1439Commonly used compiler options can be added to 'makeprg' by setting the
1440b/g:javac_makeprg_params variable.  For example: >
1441
1442	let g:javac_makeprg_params = "-Xlint:all -encoding utf-8"
1443
1444MAVEN							*compiler-maven*
1445
1446Commonly used compiler options can be added to 'makeprg' by setting the
1447b/g:maven_makeprg_params variable.  For example: >
1448
1449	let g:maven_makeprg_params = "-DskipTests -U -X"
1450
1451SPOTBUGS						*compiler-spotbugs*
1452
1453SpotBugs is a static analysis tool that can be used to find bugs in Java.
1454It scans the Java bytecode of all classes in the currently open buffer.
1455(Therefore, `:compiler! spotbugs` is not supported.)
1456
1457Commonly used compiler options can be added to 'makeprg' by setting the
1458"b:" or "g:spotbugs_makeprg_params" variable.  For example: >vim
1459
1460	let b:spotbugs_makeprg_params = "-longBugCodes -effort:max -low"
1461
1462The global default is "-workHard -experimental".
1463
1464By default, the class files are searched in the directory where the source
1465files are placed.  However, typical Java projects use distinct directories
1466for source files and class files.  To make both known to SpotBugs, assign
1467their paths (distinct and relative to their common root directory) to the
1468following properties (using the example of a common Maven project): >vim
1469
1470	let g:spotbugs_properties = {
1471		\ 'sourceDirPath':	['src/main/java'],
1472		\ 'classDirPath':	['target/classes'],
1473		\ 'testSourceDirPath':	['src/test/java'],
1474		\ 'testClassDirPath':	['target/test-classes'],
1475	\ }
1476
1477Note that source and class path entries are expected to come in pairs: define
1478both "sourceDirPath" and "classDirPath" when you are considering at least one,
1479and apply the same logic to "testSourceDirPath" and "testClassDirPath".
1480Note that values for the path keys describe only for SpotBugs where to look
1481for files; refer to the documentation for particular compiler plugins for more
1482information.
1483
1484The default pre- and post-compiler actions are provided for Ant, Maven, and
1485Javac compiler plugins and can be selected by assigning the name of a compiler
1486plugin (`ant`, `maven`, or `javac`) to the "compiler" key: >vim
1487
1488	let g:spotbugs_properties = {
1489		\ 'compiler':		'maven',
1490	\ }
1491
1492This single setting is essentially equivalent to all the settings below, with
1493the exception made for the "PreCompilerAction" and "PreCompilerTestAction"
1494values: their listed |Funcref|s will obtain no-op implementations whereas the
1495implicit Funcrefs of the "compiler" key will obtain the requested defaults if
1496available. >vim
1497
1498	let g:spotbugs_properties = {
1499		\ 'PreCompilerAction':
1500			\ function('spotbugs#DefaultPreCompilerAction'),
1501		\ 'PreCompilerTestAction':
1502			\ function('spotbugs#DefaultPreCompilerTestAction'),
1503		\ 'PostCompilerAction':
1504			\ function('spotbugs#DefaultPostCompilerAction'),
1505		\ 'sourceDirPath':	['src/main/java'],
1506		\ 'classDirPath':	['target/classes'],
1507		\ 'testSourceDirPath':	['src/test/java'],
1508		\ 'testClassDirPath':	['target/test-classes'],
1509	\ }
1510
1511With default actions, the compiler of choice will attempt to rebuild the class
1512files for the buffer (and possibly for the whole project) as soon as a Java
1513syntax file is loaded; then, `spotbugs` will attempt to analyze the quality of
1514the compilation unit of the buffer.
1515
1516Vim commands proficient in 'makeprg' [0] can be composed with default actions.
1517Begin by considering which of the supported keys, "DefaultPreCompilerCommand",
1518"DefaultPreCompilerTestCommand", or "DefaultPostCompilerCommand", you need to
1519write an implementation for, observing that each of these keys corresponds to
1520a particular "*Action" key.  Follow it by defining a new function that always
1521declares an only parameter of type string and puts to use a command equivalent
1522of |:make|, and assigning its |Funcref| to the selected key.  For example:
1523>vim
1524	function! GenericPostCompilerCommand(arguments) abort
1525		execute 'make ' .. a:arguments
1526	endfunction
1527
1528	let g:spotbugs_properties = {
1529		\ 'DefaultPostCompilerCommand':
1530			\ function('GenericPostCompilerCommand'),
1531	\ }
1532
1533When "PostCompilerAction" is available, "PostCompilerActionExecutor" is also
1534supported.  Its value must be a Funcref pointing to a function that always
1535declares a single parameter of type string and decides whether |:execute| can
1536be dispatched on its argument, containing a pending post-compiler action,
1537after ascertaining the current status of |:cc| (or |:ll|): >vim
1538
1539	function! GenericPostCompilerActionExecutor(action) abort
1540		try
1541			cc
1542		catch /\<E42:/
1543			execute a:action
1544		endtry
1545	endfunction
1546
1547Complementary, some or all of the available "Pre*Action"s (or "*Pre*Command"s)
1548may run `:doautocmd java_spotbugs_post User` in their implementations before
1549|:make| (or its equivalent) to define a once-only |ShellCmdPost| `:autocmd`
1550that will arrange for "PostCompilerActionExecutor" to be invoked; and then run
1551`:doautocmd java_spotbugs_post ShellCmdPost` to consume this event: >vim
1552
1553	function! GenericPreCompilerCommand(arguments) abort
1554		if !exists('g:spotbugs_compilation_done')
1555			doautocmd java_spotbugs_post User
1556			execute 'make ' .. a:arguments
1557			" only run doautocmd when :make was synchronous
1558			" see note below
1559			doautocmd java_spotbugs_post ShellCmdPost " XXX: (a)
1560			let g:spotbugs_compilation_done = 1
1561		else
1562			cc
1563		endif
1564	endfunction
1565
1566	function! GenericPreCompilerTestCommand(arguments) abort
1567		if !exists('g:spotbugs_test_compilation_done')
1568			doautocmd java_spotbugs_post User
1569			execute 'make ' .. a:arguments
1570			" only run doautocmd when :make was synchronous
1571			" see note below
1572			doautocmd java_spotbugs_post ShellCmdPost " XXX: (b)
1573			let g:spotbugs_test_compilation_done = 1
1574		else
1575			cc
1576		endif
1577	endfunction
1578
1579	let g:spotbugs_properties = {
1580		\ 'compiler':		'maven',
1581		\ 'DefaultPreCompilerCommand':
1582			\ function('GenericPreCompilerCommand'),
1583		\ 'DefaultPreCompilerTestCommand':
1584			\ function('GenericPreCompilerTestCommand'),
1585		\ 'PostCompilerActionExecutor':
1586			\ function('GenericPostCompilerActionExecutor'),
1587	\ }
1588
1589If a command equivalent of `:make` is capable of asynchronous execution and
1590consuming `ShellCmdPost` events, `:doautocmd java_spotbugs_post ShellCmdPost`
1591must be removed from such "*Action" (or "*Command") implementations (i.e. the
1592lines `(a)` and `(b)` in the listed examples) to retain a sequential order for
1593non-blocking execution, and any notification (see below) must be suppressed.
1594A `ShellCmdPost` `:autocmd` can be associated with any |:augroup| by assigning
1595its name to the "augroupForPostCompilerAction" key.
1596
1597When default actions are not suited to a desired workflow, proceed by writing
1598arbitrary functions yourself and matching their Funcrefs to the supported
1599keys: "PreCompilerAction", "PreCompilerTestAction", and "PostCompilerAction".
1600
1601The next example re-implements the default pre-compiler actions for a Maven
1602project and requests other default Maven settings with the "compiler" entry:
1603>vim
1604	function! MavenPreCompilerAction() abort
1605		call spotbugs#DeleteClassFiles()
1606		compiler maven
1607		make compile
1608		cc
1609	endfunction
1610
1611	function! MavenPreCompilerTestAction() abort
1612		call spotbugs#DeleteClassFiles()
1613		compiler maven
1614		make test-compile
1615		cc
1616	endfunction
1617
1618	let g:spotbugs_properties = {
1619		\ 'compiler':		'maven',
1620		\ 'PreCompilerAction':
1621			\ function('MavenPreCompilerAction'),
1622		\ 'PreCompilerTestAction':
1623			\ function('MavenPreCompilerTestAction'),
1624	\ }
1625
1626Note that all entered custom settings will take precedence over the matching
1627default settings in "g:spotbugs_properties".
1628Note that it is necessary to notify the plugin of the result of a pre-compiler
1629action before further work can be undertaken.  Using |:cc| after |:make| (or
1630|:ll| after |:lmake|) as the last command of an action is the supported means
1631of such communication.
1632
1633Two commands, "SpotBugsRemoveBufferAutocmd" and "SpotBugsDefineBufferAutocmd",
1634are provided to toggle actions for buffer-local autocommands.  For example, to
1635also run actions on any |BufWritePost| and |Signal| event, add these lines to
1636`~/.config/nvim/after/ftplugin/java.vim`: >vim
1637
1638	if exists(':SpotBugsDefineBufferAutocmd') == 2
1639		SpotBugsDefineBufferAutocmd BufWritePost Signal
1640	endif
1641
1642Otherwise, you can turn to `:doautocmd java_spotbugs User` at any time.
1643
1644The "g:spotbugs_properties" variable is consulted by the Java filetype plugin
1645(|ft-java-plugin|) to arrange for the described automation, and, therefore, it
1646must be defined before |FileType| events can take place for the buffers loaded
1647with Java source files.  It could, for example, be set in a project-local
1648|vimrc| loaded by [1].
1649
1650Both "g:spotbugs_properties" and "b:spotbugs_properties" are recognized and
1651must be modifiable (|:unlockvar|).  The "*Command" entries are always treated
1652as global functions to be shared among all Java buffers.
1653
1654The SpotBugs Java library and, by extension, its distributed shell scripts do
1655not support in the `-textui` mode listed pathnames with directory filenames
1656that contain blank characters [2].  To work around this limitation, consider
1657making a symbolic link to such a directory from a directory that does not have
1658blank characters in its name and passing this information to SpotBugs: >vim
1659
1660	let g:spotbugs_alternative_path = {
1661		\ 'fromPath':	'path/to/dir_without_blanks',
1662		\ 'toPath':	'path/to/dir with blanks',
1663	\ }
1664
1665[0] https://github.com/Konfekt/vim-compilers
1666[1] https://github.com/MarcWeber/vim-addon-local-vimrc
1667[2] https://github.com/spotbugs/spotbugs/issues/909
1668
1669GNU MAKE						*compiler-make*
1670
1671Since the default make program is "make", the compiler plugin for make,
1672:compiler make, will reset the 'makeprg' and 'errorformat' option to
1673the default values and unlet any variables that may have been set by a
1674previous compiler plugin.
1675
1676GROFF					*quickfix-groff* *compiler-groff*
1677
1678The GROFF compiler plugin uses the mom macro set (documented in the groff_mom
1679manpage) as input and expects that the output file type extension is passed to
1680make, say :make html or :make pdf.
1681
1682Additional arguments can be passed to groff by setting them in
1683`b:groff_compiler_args` or `g:groff_compiler_args`.  The `language` argument
1684passed to groff is set using 'spelllang'; it can be overridden by setting
1685`b:groff_compiler_lang`.  The default encoding is `UTF-8` and can be changed
1686by setting `b:groff_compiler_encoding` or `g:groff_compiler_encoding`.
1687
1688PANDOC					*quickfix-pandoc* *compiler-pandoc*
1689
1690The Pandoc compiler plugin expects that an output file type extension is
1691passed to make, say :make html or :make pdf.
1692
1693Additional arguments can be passed to pandoc:
1694
1695- either by appending them to make, say `:make html --self-contained` .
1696- or setting them in `b:pandoc_compiler_args` or `g:pandoc_compiler_args`.
1697
1698The `--from` argument is an educated guess using the buffer file type;
1699it can be overridden by setting `b:pandoc_compiler_from`.
1700The `--metadata lang` argument is set using 'spelllang';
1701If `--from=markdown` is assumed and no title set in a title header or
1702YAML block, then the filename (without extension) is used as the title.
1703
1704PERL					*quickfix-perl* *compiler-perl*
1705
1706The Perl compiler plugin doesn't actually compile, but invokes Perl's internal
1707syntax checking feature and parses the output for possible errors so you can
1708correct them in quick-fix mode.
1709
1710Warnings are forced regardless of "no warnings" or "$^W = 0" within the file
1711being checked.  To disable this set g:perl_compiler_force_warnings to a zero
1712value.  For example: >
1713	let g:perl_compiler_force_warnings = 0
1714
1715MYPY TYPE CHECKER					*compiler-mypy*
1716
1717Commonly used compiler options can be added to 'makeprg' by setting the
1718b/g:mypy_makeprg_params variable.  For example: >
1719
1720	let b:mypy_makeprg_params = "--warn-unused-ignores"
1721
1722The global default is "--strict --ignore-missing-imports".
1723
1724PYRIGHT TYPE CHECKER					*compiler-pyright*
1725
1726Commonly used compiler options can be added to 'makeprg' by setting the
1727b/g:pyright_makeprg_params variable.
1728
1729The global default is "pyright".
1730
1731TY TYPE CHECKER					*compiler-ty*
1732
1733Commonly used compiler options and executable can be set by the
1734b/g:ty_makeprg variable.  For example: >
1735
1736	let b:ty_makeprg = "uv run ty"
1737
1738The global default is "ty --no-progress --color=never".
1739
1740RUFF LINTER						*compiler-ruff*
1741
1742Commonly used compiler options can be added to 'makeprg' by setting the
1743b/g:ruff_makeprg_params variable.  For example: >
1744
1745	let b:ruff_makeprg_params = "--max-line-length "..&textwidth
1746
1747The global default is "--preview".
1748
1749PYLINT LINTER						*compiler-pylint*
1750
1751Commonly used compiler options can be added to 'makeprg' by setting the
1752b/g:pylint_makeprg_params variable.  For example: >
1753
1754	let b:pylint_makeprg_params = "--max-line-length "..&textwidth
1755
1756The global default is "--jobs=0" to use (almost) all cores.
1757
1758PYUNIT COMPILER						*compiler-pyunit*
1759
1760This is not actually a compiler, but a unit testing framework for the
1761Python language.  It is included into standard Python distribution
1762starting from version 2.0.  For older versions, you can get it from
1763https://pyunit.sourceforge.net.
1764
1765When you run your tests with the help of the framework, possible errors
1766are parsed by Vim and presented for you in quick-fix mode.
1767
1768Unfortunately, there is no standard way to run the tests.
1769The alltests.py script seems to be used quite often, that's all.
1770Useful values for the 'makeprg' options therefore are:
1771 setlocal makeprg=./alltests.py " Run a testsuite
1772 setlocal makeprg=python\ %:S   " Run a single testcase
1773
1774PYTEST COMPILER						*compiler-pytest*
1775Commonly used compiler options can be added to 'makeprg' by setting the
1776b/g:pytest_makeprg_params variable.  For example: >
1777
1778  let b:pytest_makeprg_params = "--verbose --no-summary --disable-warnings"
1779
1780The global default is "--tb=short --quiet"; Python warnings are suppressed.
1781
1782TEX COMPILER						*compiler-tex*
1783
1784Included in the distribution compiler for TeX ($VIMRUNTIME/compiler/tex.vim)
1785uses make command if possible.  If the compiler finds a file named "Makefile"
1786or "makefile" in the current directory, it supposes that you want to process
1787your `*TeX` files with make, and the makefile does the right work.  In this case
1788compiler sets 'errorformat' for `*TeX` output and leaves 'makeprg' untouched.
1789If neither "Makefile" nor "makefile" is found, the compiler will not use make.
1790You can force the compiler to ignore makefiles by defining
1791b:tex_ignore_makefile or g:tex_ignore_makefile variable (they are checked for
1792existence only).
1793
1794If the compiler chose not to use make, it needs to choose a right program for
1795processing your input.  If b:tex_flavor or g:tex_flavor (in this precedence)
1796variable exists, it defines TeX flavor for :make (actually, this is the name
1797of executed command), and if both variables do not exist, it defaults to
1798"latex".  For example, while editing chapter2.tex \input-ed from mypaper.tex
1799written in AMS-TeX: >
1800
1801	:let b:tex_flavor = 'amstex'
1802	:compiler tex
1803<	[editing...] >
1804	:make mypaper
1805
1806Note that you must specify a name of the file to process as an argument (to
1807process the right file when editing \input-ed or \include-ed file; portable
1808solution for substituting % for no arguments is welcome).  This is not in the
1809semantics of make, where you specify a target, not source, but you may specify
1810filename without extension ".tex" and mean this as "make filename.dvi or
1811filename.pdf or filename.some_result_extension according to compiler".
1812
1813Note: tex command line syntax is set to usable both for MikTeX (suggestion
1814by Srinath Avadhanula) and teTeX (checked by Artem Chuprina).  Suggestion
1815from |errorformat-LaTeX| is too complex to keep it working for different
1816shells and OSes and also does not allow to use other available TeX options,
1817if any.  If your TeX doesn't support "-interaction=nonstopmode", please
1818report it with different means to express \nonstopmode from the command line.
1819
1820TOMBI					*quickfix-toml* *compiler-tombi*
1821
1822The tombi compiler plugin does not compile.
1823
1824It runs "tombi lint" and parses diagnostics into the quickfix list.
1825
1826Color codes are stripped from the linter output to keep |errorformat|
1827parsing reliable.  This may require a working "sed" for old versions of the
1828tombi linter.
1829
1830TSC COMPILER						*compiler-tsc*
1831
1832The executable and compiler options can be added to 'makeprg' by setting the
1833b/g:tsc_makeprg variable.  For example: >
1834
1835	let b:tsc_makeprg = "npx tsc --noEmit"
1836
1837TYPST COMPILER						*compiler-typst*
1838
1839Vim includes a compiler plugin for Typst files.  This compiler is enabled
1840automatically in Typst buffers by the Typst filetype plugin |ft-typst-plugin|.
1841Run |:make| to compile the current Typst file.
1842
1843							*g:typst_cmd*
1844By default Vim will use "typst" as the command to run the Typst compiler.
1845This can be changed by setting the |g:typst_cmd| variable: >
1846	let g:typst_cmd = "/path/to/other/command"
1847
1848=============================================================================
18497. The error format					*error-file-format*
1850
1851					*errorformat* *E372* *E373* *E374*
1852						*E375* *E376* *E377* *E378*
1853The 'errorformat' option specifies patterns that Vim uses to read compiler
1854output.  A pattern can extract the file name, line number, column and message
1855from each line.  The first format that matches with an error message is used.
1856You can add several formats for different messages your compiler produces, or
1857even entries for multiple compilers.  See |efm-entries|.
1858
1859Each entry in 'errorformat' is a scanf-like string that describes the format.
1860First, you need to know how scanf works.  Look in the documentation of your
1861C compiler.  Below you find the % items that Vim understands.  Others are
1862invalid.
1863
1864Quick start: Vim already includes formats for many common compilers.  Check
1865|errorformats| for an example before writing your own.  If no example matches,
1866start with the basic items below and adapt one of the examples as needed.
1867
1868Special characters in 'errorformat' are comma and backslash.  See
1869|efm-entries| for how to deal with them.  Note that a literal "%" is matched
1870by "%%", thus it is not escaped with a backslash.
1871Keep in mind that in the `:make` and `:grep` output all NUL characters are
1872replaced with SOH (0x01).
1873
1874Note: By default the difference between upper and lowercase is ignored.  If
1875you want to match case, add "\C" to the pattern |/\C|.
1876
1877Vim will read lines of any length, but only the first 4095 bytes are used, the
1878rest is ignored.  Items can only be 1023 bytes long.
1879
1880
1881Basic items
1882
1883	%f		file name (finds a string)
1884	%b		buffer number (finds a number)
1885	%o		module name (finds a string)
1886	%l		line number (finds a number)
1887	%e		end line number (finds a number)
1888	%c		column number (finds a number representing character
1889			column of the error, byte index, a <tab> is 1
1890			character column)
1891	%v		virtual column number (finds a number representing the
1892			screen column of the error, where a <tab> is always 8
1893			screen columns regardless of 'tabstop')
1894	%k		end column number (finds a number representing
1895			the character column of the error, byte index, or a
1896			number representing screen end column of the error if
1897			it's used with %v)
1898	%t		error type (finds a single character):
1899			    e - error message
1900			    w - warning message
1901			    i - info message
1902			    n - note message
1903			The uppercase letters E, W, I and N are also
1904			recognized and have the same meaning.
1905	%n		error number (finds a number)
1906	%m		error message (finds a string)
1907	%r		matches the "rest" of a single-line file message %O/P/Q
1908	%p		pointer line (finds a sequence of '-', '.', ' ' or
1909			tabs and uses the length for the column number)
1910	%*{conv}	any scanf non-assignable conversion
1911	%%		the single '%' character
1912	%s		search text (finds a string)
1913
1914The "%f" conversion may depend on the current 'isfname' setting.  "~/" is
1915expanded to the home directory and environment variables are expanded.
1916
1917The "%f" and "%m" conversions have to detect the end of the string.  This
1918normally happens by matching following characters and items.  When nothing is
1919following the rest of the line is matched.  If "%f" is followed by a '%' or a
1920backslash, it will look for a sequence of 'isfname' characters.
1921
1922On Windows a leading "C:" will be included in "%f", even when using "%f:".
1923This means that a file name which is a single alphabetical letter will not be
1924detected.
1925
1926The "%b" conversion is used to parse a buffer number.  This is useful for
1927referring to lines in a scratch buffer or a buffer with no name.  If a buffer
1928with the matching number doesn't exist, then that line is used as a non-error
1929line.
1930
1931The "%p" conversion is normally followed by a "^".  It's used for compilers
1932that output a line like: >
1933	    ^
1934or >
1935   ---------^
1936to indicate the column of the error.  This is to be used in a multi-line error
1937message.  See |errorformat-javac| for a  useful example.
1938
1939The "%s" conversion specifies the text to search for, to locate the error
1940line.  The text is used as a literal string.  The anchors "^" and "$" are
1941added to the text to locate the error line exactly matching the search text
1942and the text is prefixed with the "\V" atom to make it "very nomagic".  The
1943"%s" conversion can be used to locate lines without a line number in the error
1944output.  Like the output of the "grep" shell command.
1945When the pattern is present the line number will not be used.
1946
1947The "%o" conversion specifies the module name in quickfix entry.  If present
1948it will be used in quickfix error window instead of the filename.  The module
1949name is used only for displaying purposes, the file name is used when jumping
1950to the file.
1951
1952Changing directory
1953
1954The following uppercase conversion characters specify the type of special
1955format strings.  At most one of them may be given as a prefix at the beginning
1956of a single comma-separated format pattern.
1957Some compilers produce messages that consist of directory names that have to
1958be prepended to each file name read by %f (example: GNU make).  The following
1959codes can be used to scan these directory names; they will be stored in an
1960internal directory stack.					*E379*
1961	%D		"enter directory" format string; expects a following
1962			  %f that finds the directory name
1963	%X		"leave directory" format string; expects following %f
1964
1965When defining an "enter directory" or "leave directory" format, the "%D" or
1966"%X" has to be given at the start of that substring.  Vim tracks the directory
1967changes and prepends the current directory to each erroneous file found with a
1968relative path.  See |quickfix-directory-stack| for details, tips and
1969limitations.
1970
1971
1972Multi-line messages				*errorformat-multi-line*
1973
1974It is possible to read the output of programs that produce multi-line
1975messages, i.e. error strings that consume more than one line.  Possible
1976prefixes are:
1977	%E		start of a multi-line error message
1978	%W		start of a multi-line warning message
1979	%I		start of a multi-line informational message
1980	%N		start of a multi-line note message
1981	%A		start of a multi-line message (unspecified type)
1982	%>		for next line start with current pattern again |efm-%>|
1983	%C		continuation of a multi-line message
1984	%Z		end of a multi-line message
1985These can be used with '+' and '-', see |efm-ignore| below.
1986
1987Using "\n" in the pattern won't work to match multi-line messages.
1988
1989Example: Your compiler happens to write out errors in the following format
1990(leading line numbers not being part of the actual output):
1991
1992     1	Error 275 ~
1993     2	line 42 ~
1994     3	column 3 ~
1995     4	' ' expected after '--' ~
1996
1997The appropriate error format string has to look like this: >
1998   :set efm=%EError\ %n,%Cline\ %l,%Ccolumn\ %c,%Z%m
1999
2000And the |:clist| error message generated for this error is:
2001
2002 1:42 col 3 error 275:  ' ' expected after '--'
2003
2004Another example: Think of a Python interpreter that produces the following
2005error message (line numbers are not part of the actual output):
2006
2007     1	==============================================================
2008     2	FAIL: testGetTypeIdCachesResult (dbfacadeTest.DjsDBFacadeTest)
2009     3	--------------------------------------------------------------
2010     4	Traceback (most recent call last):
2011     5	  File "unittests/dbfacadeTest.py", line 89, in testFoo
2012     6	    self.assertEquals(34, dtid)
2013     7	  File "/usr/lib/python3.8/unittest.py", line 286, in
2014     8	 failUnlessEqual
2015     9	    raise self.failureException, \
2016    10	AssertionError: 34 != 33
2017    11
2018    12	--------------------------------------------------------------
2019    13	Ran 27 tests in 0.063s
2020
2021Say you want |:clist| write the relevant information of this message only,
2022namely:
2023 5 unittests/dbfacadeTest.py:89:  AssertionError: 34 != 33
2024
2025Then the error format string could be defined as follows: >
2026  :set efm=%C\ %.%#,%A\ \ File\ \"%f\"\\,\ line\ %l%.%#,%Z%[%^\ ]%\\@=%m
2027
2028Note that the %C string is given before the %A here: since the expression
2029' %.%#' (which stands for the regular expression ' .*') matches every line
2030starting with a space, followed by any characters to the end of the line,
2031it also hides line 7 which would trigger a separate error message otherwise.
2032Error format strings are always parsed pattern by pattern until the first
2033match occurs.
2034							*efm-%>*
2035The %> item can be used to avoid trying patterns that appear earlier in
2036'errorformat'.  This is useful for patterns that match just about anything.
2037For example, if the error looks like this:
2038
2039	Error in line 123 of foo.c: ~
2040	unknown variable "i" ~
2041
2042This can be found with: >
2043	:set efm=xxx,%E%>Error in line %l of %f:,%Z%m
2044Where "xxx" has a pattern that would also match the second line.
2045
2046Important: There is no memory of what part of the errorformat matched before;
2047every line in the error file gets a complete new run through the error format
2048lines.  For example, if one has: >
2049  setlocal efm=aa,bb,cc,dd,ee
2050Where aa, bb, etc. are error format strings.  Each line of the error file will
2051be matched to the pattern aa, then bb, then cc, etc.  Just because cc matched
2052the previous error line does _not_ mean that dd will be tried first on the
2053current line, even if cc and dd are multi-line errorformat strings.
2054
2055
2056
2057Separate file name			*errorformat-separate-filename*
2058
2059These prefixes are useful if the file name is given once and multiple messages
2060follow that refer to this file name.
2061	%O		single-line file message: overread the matched part
2062	%P		single-line file message: push file %f onto the stack
2063	%Q		single-line file message: pop the last file from stack
2064
2065Example: Given a compiler that produces the following error logfile (without
2066leading line numbers):
2067
2068     1	[a1.tt]
2069     2	(1,17)  error: ';' missing
2070     3	(21,2)  warning: variable 'z' not defined
2071     4	(67,3)  error: end of file found before string ended
2072     5
2073     6	[a2.tt]
2074     7
2075     8	[a3.tt]
2076     9	NEW compiler v1.1
2077    10	(2,2)   warning: variable 'x' not defined
2078    11	(67,3)  warning: 's' already defined
2079
2080This logfile lists several messages for each file enclosed in [...] which are
2081properly parsed by an error format like this: >
2082  :set efm=%+P[%f],(%l\\,%c)%*[\ ]%t%*[^:]:\ %m,%-Q
2083
2084A call of |:clist| writes them accordingly with their correct filenames:
2085
2086  2 a1.tt:1 col 17 error: ';' missing
2087  3 a1.tt:21 col 2 warning: variable 'z' not defined
2088  4 a1.tt:67 col 3 error: end of file found before string ended
2089  8 a3.tt:2 col 2 warning: variable 'x' not defined
2090  9 a3.tt:67 col 3 warning: 's' already defined
2091
2092Unlike the other prefixes that all match against whole lines, %P, %Q and %O
2093can be used to match several patterns in the same line.  Thus it is possible
2094to parse even nested files like in the following line: >
2095  {"file1" {"file2" error1} error2 {"file3" error3 {"file4" error4 error5}}}
2096<
2097The %O then parses over strings that do not contain any push/pop file name
2098information.  See |errorformat-LaTeX| for an extended example.
2099
2100
2101Ignoring and using whole messages			*efm-ignore*
2102
2103The codes '+' or '-' can be combined with the uppercase codes above; in that
2104case they have to precede the letter, e.g. '%+A' or '%-G':
2105	%-		do not include the matching multi-line in any output
2106	%+		include the whole matching line in the %m error string
2107
2108One prefix is only useful in combination with '+' or '-', namely %G.  It
2109parses over lines containing general information like compiler version strings
2110or other headers that can be skipped.
2111	%-G		ignore this message
2112	%+G		general message
2113
2114
2115Pattern matching
2116
2117The scanf()-like "%*[]" notation is supported for backward-compatibility
2118with previous versions of Vim.  However, it is also possible to specify
2119(nearly) any Vim supported regular expression in format strings.
2120Since meta characters of the regular expression language can be part of
2121ordinary matching strings or file names (and therefore internally have to
2122be escaped), meta symbols have to be written with leading '%':
2123	%\		The single '\' character.  Note that this has to be
2124			escaped ("%\\") in ":set errorformat=" definitions.
2125	%.		The single '.' character.
2126	%#		The single "*"(!) character.
2127	%^		The single '^' character.  Note that this is not
2128			useful, the pattern already matches start of line.
2129	%$		The single '$' character.  Note that this is not
2130			useful, the pattern already matches end of line.
2131	%[		The single '[' character for a [] character range.
2132	%~		The single '~' character.
2133When using character classes in expressions (see |/\i| for an overview),
2134terms containing the "\+" quantifier can be written in the scanf() "%*"
2135notation.  Example: "%\\d%\\+" ("\d\+", "any number") is equivalent to
2136"%*\\d".
2137Important note: The \(...\) grouping of sub-matches can not be used in format
2138specifications because it is reserved for internal conversions.
2139
2140
2141Multiple entries in 'errorformat'			*efm-entries*
2142
2143To be able to detect output from several compilers, several format patterns
2144may be put in 'errorformat', separated by commas (note: blanks after the comma
2145are ignored).  The first pattern that has a complete match is used.  If no
2146match is found, matching parts from the last one will be used, although the
2147file name is removed and the error message is set to the whole message.  If
2148there is a pattern that may match output from several compilers (but not in a
2149right way), put it after one that is more restrictive.
2150
2151To include a comma in a pattern precede it with a backslash (you have to type
2152two in a ":set" command).  To include a backslash itself give two backslashes
2153(you have to type four in a ":set" command).  You also need to put a backslash
2154before a space for ":set".
2155
2156
2157Valid matches						*quickfix-valid*
2158
2159If a line does not completely match one of the entries in 'errorformat', the
2160whole line is put in the error message and the entry is marked "not valid"
2161These lines are skipped with the ":cn" and ":cp" commands (unless there is
2162no valid line at all).  You can use ":cl!" to display all the error messages.
2163
2164If the error format does not contain a file name Vim cannot switch to the
2165correct file.  You will have to do this by hand.
2166
2167
2168For example, the format of the output from the Amiga Aztec compiler is:
2169
2170	filename>linenumber:columnnumber:errortype:errornumber:errormessage
2171
2172	filename	name of the file in which the error was detected
2173	linenumber	line number where the error was detected
2174	columnnumber	column number where the error was detected
2175	errortype	type of the error, normally a single 'E' or 'W'
2176	errornumber	number of the error (for lookup in the manual)
2177	errormessage	description of the error
2178
2179This can be matched with this 'errorformat' entry:
2180	%f>%l:%c:%t:%n:%m
2181
2182Some examples for C compilers that produce single-line error outputs:
2183%f:%l:\ %t%*[^0123456789]%n:\ %m	for Manx/Aztec C error messages
2184					(scanf() doesn't understand [0-9])
2185%f\ %l\ %t%*[^0-9]%n:\ %m		for SAS C
2186\"%f\"\\,%*[^0-9]%l:\ %m		for generic C compilers
2187%f:%l:\ %m				for GCC
2188%f:%l:\ %m,%Dgmake[%*\\d]:\ Entering\ directory\ `%f',
2189%Dgmake[%*\\d]:\ Leaving\ directory\ `%f'
2190					for GCC with gmake (concat the lines!)
2191%f(%l)\ :\ %*[^:]:\ %m			old SCO C compiler (pre-OS5)
2192%f(%l)\ :\ %t%*[^0-9]%n:\ %m		idem, with error type and number
2193%f:%l:\ %m,In\ file\ included\ from\ %f:%l:,\^I\^Ifrom\ %f:%l%m
2194					for GCC, with some extras
2195
2196Extended examples for the handling of multi-line messages are given below,
2197see |errorformat-Jikes| and |errorformat-LaTeX|.
2198
2199Note the backslash in front of a space and double quote.  It is required for
2200the :set command.  There are two backslashes in front of a comma, one for the
2201:set command and one to avoid recognizing the comma as a separator of error
2202formats.
2203
2204
2205Filtering messages
2206
2207If you have a compiler that produces error messages that do not fit in the
2208format string, you could write a program that translates the error messages
2209into this format.  You can use this program with the ":make" command by
2210changing the 'makeprg' option.  For example: >
2211   :set mp=make\ \\\|&\ error_filter
2212The backslashes before the pipe character are required to avoid it to be
2213recognized as a command separator.  The backslash before each space is
2214required for the set command.
2215
2216=============================================================================
22178. The directory stack				*quickfix-directory-stack*
2218
2219Quickfix maintains a stack for saving all used directories parsed from the
2220make output.  For GNU-make this is rather simple, as it always prints the
2221absolute path of all directories it enters and leaves.  Regardless if this is
2222done via a 'cd' command in the makefile or with the parameter "-C dir" (change
2223to directory before reading the makefile).  It may be useful to use the switch
2224"-w" to force GNU-make to print out the working directory before and after
2225processing.
2226
2227This matters only when compiler output contains relative file names from
2228multiple directories.  If the output does not clearly report directory
2229changes, Vim has to guess and can select the wrong file.  Printing absolute
2230directory names and both entering and leaving directory messages avoids this
2231problem.
2232
2233Maintaining the correct directory is more complicated if you don't use
2234GNU-make.  AIX-make for example doesn't print any information about its
2235working directory.  Then you need to enhance the makefile.  In the makefile of
2236LessTif there is a command which echoes "Making {target} in {dir}".  The
2237special problem here is that it doesn't print information on leaving the
2238directory and that it doesn't print the absolute path.
2239
2240To solve the problem with relative paths and missing "leave directory"
2241messages Vim uses the following algorithm:
2242
22431) Check if the given directory is a subdirectory of the current directory.
2244   If this is true, store it as the current directory.
22452) If it is not a subdir of the current directory, try if this is a
2246   subdirectory of one of the upper directories.
22473) If the directory still isn't found, it is assumed to be a subdirectory
2248   of Vim's current directory.
2249
2250Additionally it is checked for every file, if it really exists in the
2251identified directory.  If not, it is searched in all other directories of the
2252directory stack (NOT the directory subtree!).  If it is still not found, it is
2253assumed that it is in Vim's current directory.
2254
2255There are limitations in this algorithm.  These examples assume that make just
2256prints information about entering a directory in the form "Making all in dir".
2257
22581) Assume you have following directories and files:
2259   ./dir1
2260   ./dir1/file1.c
2261   ./file1.c
2262
2263   If make processes the directory "./dir1" before the current directory and
2264   there is an error in the file "./file1.c", you will end up with the file
2265   "./dir1/file.c" loaded by Vim.
2266
2267   This can only be solved with a "leave directory" message.
2268
22692) Assume you have following directories and files:
2270   ./dir1
2271   ./dir1/dir2
2272   ./dir2
2273
2274   You get the following:
2275
2276   Make output			  Directory interpreted by Vim
2277   ------------------------	  ----------------------------
2278   Making all in dir1		  ./dir1
2279   Making all in dir2		  ./dir1/dir2
2280   Making all in dir2		  ./dir1/dir2
2281
2282   This can be solved by printing absolute directories in the "enter
2283   directory" message or by printing "leave directory" messages.
2284
2285To avoid this problem, ensure to print absolute directory names and "leave
2286directory" messages.
2287
2288Examples for Makefiles:
2289
2290Unix:
2291    libs:
2292	    for dn in $(LIBDIRS); do				\
2293		(cd $$dn; echo "Entering dir '$$(pwd)'"; make); \
2294		echo "Leaving dir";				\
2295	    done
2296
2297Add
2298    %DEntering\ dir\ '%f',%XLeaving\ dir
2299to your 'errorformat' to handle the above output.
2300
2301Note that Vim doesn't check if the directory name in a "leave directory"
2302messages is the current directory.  This is why you could just use the message
2303"Leaving dir".
2304
2305=============================================================================
23069. Specific error file formats			*errorformats*
2307
2308						*errorformat-Jikes*
2309Jikes(TM), a source-to-bytecode Java compiler published by IBM Research,
2310produces simple multi-line error messages.
2311
2312An 'errorformat' string matching the produced messages is shown below.
2313The following lines can be placed in the user's |init.vim| to overwrite Vim's
2314recognized default formats, or see |:set+=| how to install this format
2315additionally to the default. >
2316
2317  :set efm=%A%f:%l:%c:%*\\d:%*\\d:,
2318	\%C%*\\s%trror:%m,
2319	\%+C%*[^:]%trror:%m,
2320	\%C%*\\s%tarning:%m,
2321	\%C%m
2322<
2323Jikes(TM) produces a single-line error message when invoked with the option
2324"+E", and can be matched with the following: >
2325
2326  :setl efm=%f:%l:%v:%*\\d:%*\\d:%*\\s%m
2327<
2328						*errorformat-javac*
2329This 'errorformat' has been reported to work well for javac, which outputs a
2330line with "^" to indicate the column of the error: >
2331  :setl efm=%A%f:%l:\ %m,%-Z%p^,%-C%.%#
2332or: >
2333  :setl efm=%A%f:%l:\ %m,%+Z%p^,%+C%.%#,%-G%.%#
2334<
2335Here is an alternative from Michael F. Lamb for Unix that filters the errors
2336first: >
2337  :setl errorformat=%Z%f:%l:\ %m,%A%p^,%-G%*[^sl]%.%#
2338  :setl makeprg=javac\ %:S\ 2>&1\ \\\|\ vim-javac-filter
2339
2340You need to put the following in "vim-javac-filter" somewhere in your path
2341(e.g., in ~/bin) and make it executable: >
2342   #!/bin/sed -f
2343   /\^$/s/\t/\ /g;/:[0-9]\+:/{h;d};/^[ \t]*\^/G;
2344
2345In English, that sed script:
2346- Changes single tabs to single spaces and
2347- Moves the line with the filename, line number, error message to just after
2348  the pointer line.  That way, the unused error text between doesn't break
2349  vim's notion of a "multi-line message" and also doesn't force us to include
2350  it as a "continuation of a multi-line message."
2351
2352						*errorformat-ant*
2353For ant (https://jakarta.apache.org/) the above errorformat has to be modified
2354to honour the leading [javac] in front of each javac output line: >
2355  :set efm=%A\ %#[javac]\ %f:%l:\ %m,%-Z\ %#[javac]\ %p^,%-C%.%#
2356
2357The 'errorformat' can also be configured to handle ant together with either
2358javac or jikes.  If you're using jikes, you should tell ant to use jikes' +E
2359command line switch which forces jikes to generate one-line error messages.
2360This is what the second line (of a build.xml file) below does: >
2361  <property name = "build.compiler"       value = "jikes"/>
2362  <property name = "build.compiler.emacs" value = "true"/>
2363
2364The 'errorformat' which handles ant with both javac and jikes is: >
2365  :set efm=\ %#[javac]\ %#%f:%l:%c:%*\\d:%*\\d:\ %t%[%^:]%#:%m,
2366	   \%A\ %#[javac]\ %f:%l:\ %m,%-Z\ %#[javac]\ %p^,%-C%.%#
2367<
2368						*errorformat-jade*
2369parsing jade (see http://www.jclark.com/) errors is simple: >
2370  :set efm=jade:%f:%l:%c:%t:%m
2371<
2372						*errorformat-LaTeX*
2373The following is an example how an 'errorformat' string can be specified
2374for the (La)TeX typesetting system which displays error messages over
2375multiple lines.  The output of ":clist" and ":cc" etc. commands displays
2376multi-lines in a single line, leading white space is removed.
2377It should be easy to adopt the above LaTeX errorformat to any compiler output
2378consisting of multi-line errors.
2379
2380The commands can be placed in a |vimrc| file or some other Vim script file,
2381e.g. a script containing LaTeX related stuff which is loaded only when editing
2382LaTeX sources.
2383Make sure to copy all lines of the example (in the given order), afterwards
2384remove the comment lines.  For the '\' notation at the start of some lines see
2385|line-continuation|.
2386
2387		First prepare 'makeprg' such that LaTeX will report multiple
2388		errors; do not stop when the first error has occurred: >
2389 :set makeprg=latex\ \\\\nonstopmode\ \\\\input\\{$*}
2390<
2391		Start of multi-line error messages: >
2392 :set efm=%E!\ LaTeX\ %trror:\ %m,
2393	\%E!\ %m,
2394<		Start of multi-line warning messages; the first two also
2395		include the line number.  Meaning of some regular expressions:
2396		  - "%.%#"  (`.*`)   matches a (possibly empty) string
2397		  - "%*\\d" ("\d\+") matches a number >
2398	\%+WLaTeX\ %.%#Warning:\ %.%#line\ %l%.%#,
2399	\%+W%.%#\ at\ lines\ %l--%*\\d,
2400	\%WLaTeX\ %.%#Warning:\ %m,
2401<		Possible continuations of error/warning messages; the first
2402		one also includes the line number: >
2403	\%Cl.%l\ %m,
2404	\%+C\ \ %m.,
2405	\%+C%.%#-%.%#,
2406	\%+C%.%#[]%.%#,
2407	\%+C[]%.%#,
2408	\%+C%.%#%[{}\\]%.%#,
2409	\%+C<%.%#>%.%#,
2410	\%C\ \ %m,
2411<		Lines that match the following patterns do not contain any
2412		important information; do not include them in messages: >
2413	\%-GSee\ the\ LaTeX%m,
2414	\%-GType\ \ H\ <return>%m,
2415	\%-G\ ...%.%#,
2416	\%-G%.%#\ (C)\ %.%#,
2417	\%-G(see\ the\ transcript%.%#),
2418<		Generally exclude any empty or whitespace-only line from
2419		being displayed: >
2420	\%-G\\s%#,
2421<		The LaTeX output log does not specify the names of erroneous
2422		source files per line; rather they are given globally,
2423		enclosed in parentheses.
2424		The following patterns try to match these names and store
2425		them in an internal stack.  The patterns possibly scan over
2426		the same input line (one after another), the trailing "%r"
2427		conversion indicates the "rest" of the line that will be
2428		parsed in the next go until the end of line is reached.
2429
2430		Overread a file name enclosed in '('...')'; do not push it
2431		on a stack since the file apparently does not contain any
2432		error: >
2433	\%+O(%f)%r,
2434<		Push a file name onto the stack.  The name is given after '(': >
2435	\%+P(%f%r,
2436	\%+P\ %\\=(%f%r,
2437	\%+P%*[^()](%f%r,
2438	\%+P[%\\d%[^()]%#(%f%r,
2439<		Pop the last stored file name when a ')' is scanned: >
2440	\%+Q)%r,
2441	\%+Q%*[^()])%r,
2442	\%+Q[%\\d%*[^()])%r
2443
2444Note that in some cases file names in the LaTeX output log cannot be parsed
2445properly.  The parser might have been messed up by unbalanced parentheses
2446then.  The above example tries to catch the most relevant cases only.
2447You can customize the given setting to suit your own purposes, for example,
2448all the annoying "Overfull ..." warnings could be excluded from being
2449recognized as an error.
2450Alternatively to filtering the LaTeX compiler output, it is also possible
2451to directly read the `*.log` file that is produced by the [La]TeX compiler.
2452This contains even more useful information about possible error causes.
2453However, to properly parse such a complex file, an external filter should
2454be used.  See the description further above how to make such a filter known
2455by Vim.
2456
2457
2458=============================================================================
245910. Customizing the quickfix window		*quickfix-window-function*
2460
2461The default format for the lines displayed in the quickfix window and location
2462list window is:
2463>
2464    <filename>|<lnum> col <col>|<text>
2465<
2466The values displayed in each line correspond to the "bufnr", "lnum", "col" and
2467"text" fields returned by the |getqflist()| function.
2468
2469For some quickfix/location lists, the displayed text needs to be customized.
2470For example, if only the filename is present for a quickfix entry, then the
2471two "|" field separator characters after the filename are not needed.  Another
2472use case is to customize the path displayed for a filename.  By default, the
2473complete path (which may be too long) is displayed for files which are not
2474under the current directory tree.  The file path may need to be simplified to
2475a common parent directory.
2476
2477The displayed text can be customized by setting the 'quickfixtextfunc' option
2478to a Vim function.  This function will be called with a dict argument and
2479should return a List of strings to be displayed in the quickfix or location
2480list window.  The dict argument will have the following fields:
2481
2482    quickfix	set to 1 when called for a quickfix list and 0 when called for
2483		a location list.
2484    winid	for a location list, set to the id of the window with the
2485		location list.  For a quickfix list, set to 0.  Can be used in
2486		getloclist() to get the location list entry.
2487    id		quickfix or location list identifier
2488    start_idx	index of the first entry for which text should be returned
2489    end_idx	index of the last entry for which text should be returned
2490
2491The function should return a single line of text to display in the quickfix
2492window for each entry from start_idx to end_idx.  The function can obtain
2493information about the entries using the |getqflist()| function and specifying
2494the quickfix list identifier "id".  For a location list, getloclist() function
2495can be used with the "winid" argument.  If an empty list is returned, then the
2496default format is used to display all the entries.  If an item in the returned
2497list is an empty string, then the default format is used to display the
2498corresponding entry.
2499
2500If a quickfix or location list specific customization is needed, then the
2501'quickfixtextfunc' attribute of the list can be set using the |setqflist()| or
2502|setloclist()| function.  This overrides the global 'quickfixtextfunc' option.
2503
2504The example below displays the list of old files (|v:oldfiles|) in a quickfix
2505window.  As there is no line, column number and error text information
2506associated with each entry, the 'quickfixtextfunc' function returns only the
2507filename.
2508Example: >
2509    " create a quickfix list from v:oldfiles
2510    call setqflist([], ' ', {'lines' : v:oldfiles, 'efm' : '%f',
2511					\ 'quickfixtextfunc' : 'QfOldFiles'})
2512    func QfOldFiles(info)
2513	" get information about a range of quickfix entries
2514	let items = getqflist({'id' : a:info.id, 'items' : 1}).items
2515	let l = []
2516	for idx in range(a:info.start_idx - 1, a:info.end_idx - 1)
2517	    " use the simplified file name
2518	  call add(l, fnamemodify(bufname(items[idx].bufnr), ':p:.'))
2519	endfor
2520	return l
2521    endfunc
2522<
2523
2524 vim:tw=78:ts=8:noet:ft=help:norl: