neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

quickfix.txt (99587B)


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