Mercurial > vim
annotate runtime/doc/quickfix.txt @ 10454:f5c7c76897fa v8.0.0120
commit https://github.com/vim/vim/commit/5643db84c6a9f15d14492cefd52647623aa2ac7c
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Dec 3 14:29:10 2016 +0100
patch 8.0.0120
Problem: Channel test is still flaky on OS X.
Solution: Set the drop argument to "never".
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 03 Dec 2016 14:30:04 +0100 |
parents | c78513465e6e |
children | 1218c5353e2b |
rev | line source |
---|---|
10348
c78513465e6e
commit https://github.com/vim/vim/commit/25de4c232d580583feadae11ab34e3cc6333c350
Christian Brabandt <cb@256bit.org>
parents:
10198
diff
changeset
|
1 *quickfix.txt* For Vim version 8.0. Last change: 2016 Nov 04 |
7 | 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 1. Using QuickFix commands |quickfix| | |
10 2. The error window |quickfix-window| | |
11 3. Using more than one list of errors |quickfix-error-lists| | |
12 4. Using :make |:make_makeprg| | |
13 5. Using :grep |grep| | |
14 6. Selecting a compiler |compiler-select| | |
15 7. The error format |error-file-format| | |
16 8. The directory stack |quickfix-directory-stack| | |
17 9. Specific error file formats |errorformats| | |
18 | |
19 {Vi does not have any of these commands} | |
20 | |
21 The quickfix commands are not available when the |+quickfix| feature was | |
22 disabled at compile time. | |
23 | |
24 ============================================================================= | |
25 1. Using QuickFix commands *quickfix* *Quickfix* *E42* | |
26 | |
27 Vim has a special mode to speedup the edit-compile-edit cycle. This is | |
28 inspired by the quickfix option of the Manx's Aztec C compiler on the Amiga. | |
29 The idea is to save the error messages from the compiler in a file and use Vim | |
30 to jump to the errors one by one. You can examine each problem and fix it, | |
31 without having to remember all the error messages. | |
32 | |
170 | 33 In Vim the quickfix commands are used more generally to find a list of |
34 positions in files. For example, |:vimgrep| finds pattern matches. You can | |
231 | 35 use the positions in a script with the |getqflist()| function. Thus you can |
170 | 36 do a lot more than the edit/compile/fix cycle! |
37 | |
9407
619a98a67f67
commit https://github.com/vim/vim/commit/e18dbe865d190e74fb5d43ac8bc6ac22507d0223
Christian Brabandt <cb@256bit.org>
parents:
9379
diff
changeset
|
38 If you have the error messages in a file you can start Vim with: > |
619a98a67f67
commit https://github.com/vim/vim/commit/e18dbe865d190e74fb5d43ac8bc6ac22507d0223
Christian Brabandt <cb@256bit.org>
parents:
9379
diff
changeset
|
39 vim -q filename |
619a98a67f67
commit https://github.com/vim/vim/commit/e18dbe865d190e74fb5d43ac8bc6ac22507d0223
Christian Brabandt <cb@256bit.org>
parents:
9379
diff
changeset
|
40 |
619a98a67f67
commit https://github.com/vim/vim/commit/e18dbe865d190e74fb5d43ac8bc6ac22507d0223
Christian Brabandt <cb@256bit.org>
parents:
9379
diff
changeset
|
41 From inside Vim an easy way to run a command and handle the output is with the |
619a98a67f67
commit https://github.com/vim/vim/commit/e18dbe865d190e74fb5d43ac8bc6ac22507d0223
Christian Brabandt <cb@256bit.org>
parents:
9379
diff
changeset
|
42 |:make| command (see below). |
619a98a67f67
commit https://github.com/vim/vim/commit/e18dbe865d190e74fb5d43ac8bc6ac22507d0223
Christian Brabandt <cb@256bit.org>
parents:
9379
diff
changeset
|
43 |
619a98a67f67
commit https://github.com/vim/vim/commit/e18dbe865d190e74fb5d43ac8bc6ac22507d0223
Christian Brabandt <cb@256bit.org>
parents:
9379
diff
changeset
|
44 The 'errorformat' option should be set to match the error messages from your |
7 | 45 compiler (see |errorformat| below). |
46 | |
644 | 47 *location-list* *E776* |
648 | 48 A location list is similar to a quickfix list and contains a list of positions |
49 in files. A location list is associated with a window and each window can | |
50 have a separate location list. A location list can be associated with only | |
51 one window. The location list is independent of the quickfix list. | |
644 | 52 |
648 | 53 When a window with a location list is split, the new window gets a copy of the |
9407
619a98a67f67
commit https://github.com/vim/vim/commit/e18dbe865d190e74fb5d43ac8bc6ac22507d0223
Christian Brabandt <cb@256bit.org>
parents:
9379
diff
changeset
|
54 location list. When there are no longer any references to a location list, |
619a98a67f67
commit https://github.com/vim/vim/commit/e18dbe865d190e74fb5d43ac8bc6ac22507d0223
Christian Brabandt <cb@256bit.org>
parents:
9379
diff
changeset
|
55 the location list is destroyed. |
648 | 56 |
57 The following quickfix commands can be used. The location list commands are | |
58 similar to the quickfix commands, replacing the 'c' prefix in the quickfix | |
59 command with 'l'. | |
7 | 60 |
8673
ed7251c3e2d3
commit https://github.com/vim/vim/commit/e18c0b39815c5a746887a509c2cd9f11fadaba07
Christian Brabandt <cb@256bit.org>
parents:
7707
diff
changeset
|
61 *E924* |
ed7251c3e2d3
commit https://github.com/vim/vim/commit/e18c0b39815c5a746887a509c2cd9f11fadaba07
Christian Brabandt <cb@256bit.org>
parents:
7707
diff
changeset
|
62 If the current window was closed by an |autocommand| while processing a |
ed7251c3e2d3
commit https://github.com/vim/vim/commit/e18c0b39815c5a746887a509c2cd9f11fadaba07
Christian Brabandt <cb@256bit.org>
parents:
7707
diff
changeset
|
63 location list command, it will be aborted. |
ed7251c3e2d3
commit https://github.com/vim/vim/commit/e18c0b39815c5a746887a509c2cd9f11fadaba07
Christian Brabandt <cb@256bit.org>
parents:
7707
diff
changeset
|
64 |
8702
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8673
diff
changeset
|
65 *E925* *E926* |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8673
diff
changeset
|
66 If the current quickfix or location list was changed by an |autocommand| while |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8673
diff
changeset
|
67 processing a quickfix or location list command, it will be aborted. |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8673
diff
changeset
|
68 |
7 | 69 *:cc* |
70 :cc[!] [nr] Display error [nr]. If [nr] is omitted, the same | |
71 error is displayed again. Without [!] this doesn't | |
72 work when jumping to another buffer, the current buffer | |
73 has been changed, there is the only window for the | |
74 buffer and both 'hidden' and 'autowrite' are off. | |
75 When jumping to another buffer with [!] any changes to | |
76 the current buffer are lost, unless 'hidden' is set or | |
77 there is another window for this buffer. | |
78 The 'switchbuf' settings are respected when jumping | |
79 to a buffer. | |
80 | |
644 | 81 *:ll* |
82 :ll[!] [nr] Same as ":cc", except the location list for the | |
83 current window is used instead of the quickfix list. | |
84 | |
7 | 85 *:cn* *:cnext* *E553* |
86 :[count]cn[ext][!] Display the [count] next error in the list that | |
87 includes a file name. If there are no file names at | |
88 all, go to the [count] next error. See |:cc| for | |
89 [!] and 'switchbuf'. | |
90 | |
647 | 91 *:lne* *:lnext* |
92 :[count]lne[xt][!] Same as ":cnext", except the location list for the | |
644 | 93 current window is used instead of the quickfix list. |
94 | |
7 | 95 :[count]cN[ext][!] *:cp* *:cprevious* *:cN* *:cNext* |
96 :[count]cp[revious][!] Display the [count] previous error in the list that | |
97 includes a file name. If there are no file names at | |
98 all, go to the [count] previous error. See |:cc| for | |
99 [!] and 'switchbuf'. | |
100 | |
856 | 101 |
647 | 102 :[count]lN[ext][!] *:lp* *:lprevious* *:lN* *:lNext* |
644 | 103 :[count]lp[revious][!] Same as ":cNext" and ":cprevious", except the location |
104 list for the current window is used instead of the | |
105 quickfix list. | |
106 | |
7 | 107 *:cnf* *:cnfile* |
108 :[count]cnf[ile][!] Display the first error in the [count] next file in | |
109 the list that includes a file name. If there are no | |
110 file names at all or if there is no next file, go to | |
111 the [count] next error. See |:cc| for [!] and | |
112 'switchbuf'. | |
113 | |
644 | 114 *:lnf* *:lnfile* |
115 :[count]lnf[ile][!] Same as ":cnfile", except the location list for the | |
116 current window is used instead of the quickfix list. | |
117 | |
7 | 118 :[count]cNf[ile][!] *:cpf* *:cpfile* *:cNf* *:cNfile* |
119 :[count]cpf[ile][!] Display the last error in the [count] previous file in | |
120 the list that includes a file name. If there are no | |
121 file names at all or if there is no next file, go to | |
122 the [count] previous error. See |:cc| for [!] and | |
123 'switchbuf'. | |
124 | |
647 | 125 |
126 :[count]lNf[ile][!] *:lpf* *:lpfile* *:lNf* *:lNfile* | |
644 | 127 :[count]lpf[ile][!] Same as ":cNfile" and ":cpfile", except the location |
128 list for the current window is used instead of the | |
129 quickfix list. | |
130 | |
7 | 131 *:crewind* *:cr* |
132 :cr[ewind][!] [nr] Display error [nr]. If [nr] is omitted, the FIRST | |
133 error is displayed. See |:cc|. | |
134 | |
644 | 135 *:lrewind* *:lr* |
136 :lr[ewind][!] [nr] Same as ":crewind", except the location list for the | |
137 current window is used instead of the quickfix list. | |
138 | |
7 | 139 *:cfirst* *:cfir* |
140 :cfir[st][!] [nr] Same as ":crewind". | |
141 | |
644 | 142 *:lfirst* *:lfir* |
143 :lfir[st][!] [nr] Same as ":lrewind". | |
144 | |
7 | 145 *:clast* *:cla* |
146 :cla[st][!] [nr] Display error [nr]. If [nr] is omitted, the LAST | |
147 error is displayed. See |:cc|. | |
148 | |
644 | 149 *:llast* *:lla* |
150 :lla[st][!] [nr] Same as ":clast", except the location list for the | |
151 current window is used instead of the quickfix list. | |
152 | |
7 | 153 *:cq* *:cquit* |
1624 | 154 :cq[uit][!] Quit Vim with an error code, so that the compiler |
7 | 155 will not compile the same file again. |
1624 | 156 WARNING: All changes in files are lost! Also when the |
157 [!] is not used. It works like ":qall!" |:qall|, | |
158 except that Vim returns a non-zero exit code. | |
7 | 159 |
160 *:cf* *:cfile* | |
161 :cf[ile][!] [errorfile] Read the error file and jump to the first error. | |
162 This is done automatically when Vim is started with | |
163 the -q option. You can use this command when you | |
164 keep Vim running while compiling. If you give the | |
165 name of the errorfile, the 'errorfile' option will | |
166 be set to [errorfile]. See |:cc| for [!]. | |
167 | |
644 | 168 *:lf* *:lfile* |
169 :lf[ile][!] [errorfile] Same as ":cfile", except the location list for the | |
170 current window is used instead of the quickfix list. | |
171 You can not use the -q command-line option to set | |
172 the location list. | |
173 | |
856 | 174 |
1624 | 175 :cg[etfile] [errorfile] *:cg* *:cgetfile* |
7 | 176 Read the error file. Just like ":cfile" but don't |
177 jump to the first error. | |
178 | |
856 | 179 |
1624 | 180 :lg[etfile] [errorfile] *:lg* *:lgetfile* |
644 | 181 Same as ":cgetfile", except the location list for the |
182 current window is used instead of the quickfix list. | |
183 | |
625 | 184 *:caddf* *:caddfile* |
185 :caddf[ile] [errorfile] Read the error file and add the errors from the | |
446 | 186 errorfile to the current quickfix list. If a quickfix |
187 list is not present, then a new list is created. | |
188 | |
644 | 189 *:laddf* *:laddfile* |
190 :laddf[ile] [errorfile] Same as ":caddfile", except the location list for the | |
191 current window is used instead of the quickfix list. | |
192 | |
41 | 193 *:cb* *:cbuffer* *E681* |
1084 | 194 :cb[uffer][!] [bufnr] Read the error list from the current buffer. |
41 | 195 When [bufnr] is given it must be the number of a |
196 loaded buffer. That buffer will then be used instead | |
197 of the current buffer. | |
198 A range can be specified for the lines to be used. | |
199 Otherwise all lines in the buffer are used. | |
1084 | 200 See |:cc| for [!]. |
41 | 201 |
644 | 202 *:lb* *:lbuffer* |
1084 | 203 :lb[uffer][!] [bufnr] Same as ":cbuffer", except the location list for the |
644 | 204 current window is used instead of the quickfix list. |
205 | |
798 | 206 *:cgetb* *:cgetbuffer* |
207 :cgetb[uffer] [bufnr] Read the error list from the current buffer. Just | |
208 like ":cbuffer" but don't jump to the first error. | |
209 | |
210 *:lgetb* *:lgetbuffer* | |
211 :lgetb[uffer] [bufnr] Same as ":cgetbuffer", except the location list for | |
212 the current window is used instead of the quickfix | |
213 list. | |
214 | |
5734 | 215 *:cad* *:caddbuffer* |
5763 | 216 :cad[dbuffer] [bufnr] Read the error list from the current buffer and add |
658 | 217 the errors to the current quickfix list. If a |
218 quickfix list is not present, then a new list is | |
219 created. Otherwise, same as ":cbuffer". | |
220 | |
221 *:laddb* *:laddbuffer* | |
222 :laddb[uffer] [bufnr] Same as ":caddbuffer", except the location list for | |
223 the current window is used instead of the quickfix | |
224 list. | |
225 | |
626 | 226 *:cex* *:cexpr* *E777* |
625 | 227 :cex[pr][!] {expr} Create a quickfix list using the result of {expr} and |
2833 | 228 jump to the first error. |
229 If {expr} is a String, then each new-line terminated | |
7701
075810b0cb6c
commit https://github.com/vim/vim/commit/d6357e8f93c50f984ffd69c3a0d247d8603f86c3
Christian Brabandt <cb@256bit.org>
parents:
7418
diff
changeset
|
230 line in the String is processed using the global value |
075810b0cb6c
commit https://github.com/vim/vim/commit/d6357e8f93c50f984ffd69c3a0d247d8603f86c3
Christian Brabandt <cb@256bit.org>
parents:
7418
diff
changeset
|
231 of 'errorformat' and the result is added to the |
075810b0cb6c
commit https://github.com/vim/vim/commit/d6357e8f93c50f984ffd69c3a0d247d8603f86c3
Christian Brabandt <cb@256bit.org>
parents:
7418
diff
changeset
|
232 quickfix list. |
2833 | 233 If {expr} is a List, then each String item in the list |
234 is processed and added to the quickfix list. Non | |
235 String items in the List are ignored. | |
236 See |:cc| for [!]. | |
446 | 237 Examples: > |
238 :cexpr system('grep -n xyz *') | |
239 :cexpr getline(1, '$') | |
240 < | |
644 | 241 *:lex* *:lexpr* |
2833 | 242 :lex[pr][!] {expr} Same as |:cexpr|, except the location list for the |
644 | 243 current window is used instead of the quickfix list. |
244 | |
800 | 245 *:cgete* *:cgetexpr* |
1624 | 246 :cgete[xpr] {expr} Create a quickfix list using the result of {expr}. |
2833 | 247 Just like |:cexpr|, but don't jump to the first error. |
800 | 248 |
249 *:lgete* *:lgetexpr* | |
2833 | 250 :lgete[xpr] {expr} Same as |:cgetexpr|, except the location list for the |
800 | 251 current window is used instead of the quickfix list. |
252 | |
5734 | 253 *:cadde* *:caddexpr* |
5763 | 254 :cadde[xpr] {expr} Evaluate {expr} and add the resulting lines to the |
625 | 255 current quickfix list. If a quickfix list is not |
256 present, then a new list is created. The current | |
257 cursor position will not be changed. See |:cexpr| for | |
258 more information. | |
259 Example: > | |
260 :g/mypattern/caddexpr expand("%") . ":" . line(".") . ":" . getline(".") | |
261 < | |
644 | 262 *:lad* *:laddexpr* |
1624 | 263 :lad[dexpr] {expr} Same as ":caddexpr", except the location list for the |
644 | 264 current window is used instead of the quickfix list. |
265 | |
7 | 266 *:cl* *:clist* |
267 :cl[ist] [from] [, [to]] | |
268 List all errors that are valid |quickfix-valid|. | |
269 If numbers [from] and/or [to] are given, the respective | |
237 | 270 range of errors is listed. A negative number counts |
7 | 271 from the last error backwards, -1 being the last error. |
272 The 'switchbuf' settings are respected when jumping | |
273 to a buffer. | |
274 | |
9379
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9227
diff
changeset
|
275 :cl[ist] +{count} List the current and next {count} valid errors. This |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9227
diff
changeset
|
276 is similar to ":clist from from+count", where "from" |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9227
diff
changeset
|
277 is the current error position. |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9227
diff
changeset
|
278 |
7 | 279 :cl[ist]! [from] [, [to]] |
280 List all errors. | |
281 | |
9379
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9227
diff
changeset
|
282 :cl[ist]! +{count} List the current and next {count} error lines. This |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9227
diff
changeset
|
283 is useful to see unrecognized lines after the current |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9227
diff
changeset
|
284 one. For example, if ":clist" shows: |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9227
diff
changeset
|
285 8384 testje.java:252: error: cannot find symbol ~ |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9227
diff
changeset
|
286 Then using ":cl! +3" shows the reason: |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9227
diff
changeset
|
287 8384 testje.java:252: error: cannot find symbol ~ |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9227
diff
changeset
|
288 8385: ZexitCode = Fmainx(); ~ |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9227
diff
changeset
|
289 8386: ^ ~ |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9227
diff
changeset
|
290 8387: symbol: method Fmainx() ~ |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9227
diff
changeset
|
291 |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9227
diff
changeset
|
292 :lli[st] [from] [, [to]] *:lli* *:llist* |
644 | 293 Same as ":clist", except the location list for the |
294 current window is used instead of the quickfix list. | |
295 | |
296 :lli[st]! [from] [, [to]] | |
297 List all the entries in the location list for the | |
298 current window. | |
299 | |
7 | 300 If you insert or delete lines, mostly the correct error location is still |
301 found because hidden marks are used. Sometimes, when the mark has been | |
302 deleted for some reason, the message "line changed" is shown to warn you that | |
303 the error location may not be correct. If you quit Vim and start again the | |
304 marks are lost and the error locations may not be correct anymore. | |
305 | |
163 | 306 If vim is built with |+autocmd| support, two autocommands are available for |
307 running commands before and after a quickfix command (':make', ':grep' and so | |
308 on) is executed. See |QuickFixCmdPre| and |QuickFixCmdPost| for details. | |
309 | |
1624 | 310 *QuickFixCmdPost-example* |
311 When 'encoding' differs from the locale, the error messages may have a | |
312 different encoding from what Vim is using. To convert the messages you can | |
313 use this code: > | |
314 function QfMakeConv() | |
315 let qflist = getqflist() | |
316 for i in qflist | |
317 let i.text = iconv(i.text, "cp936", "utf-8") | |
318 endfor | |
319 call setqflist(qflist) | |
320 endfunction | |
321 | |
322 au QuickfixCmdPost make call QfMakeConv() | |
323 | |
324 | |
7100
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
325 EXECUTE A COMMAND IN ALL THE BUFFERS IN QUICKFIX OR LOCATION LIST: |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
326 *:cdo* |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
327 :cdo[!] {cmd} Execute {cmd} in each valid entry in the quickfix list. |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
328 It works like doing this: > |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
329 :cfirst |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
330 :{cmd} |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
331 :cnext |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
332 :{cmd} |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
333 etc. |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
334 < When the current file can't be |abandon|ed and the [!] |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
335 is not present, the command fails. |
9379
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9227
diff
changeset
|
336 When an error is detected execution stops. |
7100
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
337 The last buffer (or where an error occurred) becomes |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
338 the current buffer. |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
339 {cmd} can contain '|' to concatenate several commands. |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
340 |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
341 Only valid entries in the quickfix list are used. |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
342 A range can be used to select entries, e.g.: > |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
343 :10,$cdo cmd |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
344 < To skip entries 1 to 9. |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
345 |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
346 Note: While this command is executing, the Syntax |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
347 autocommand event is disabled by adding it to |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
348 'eventignore'. This considerably speeds up editing |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
349 each buffer. |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
350 {not in Vi} {not available when compiled without the |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
351 |+listcmds| feature} |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
352 Also see |:bufdo|, |:tabdo|, |:argdo|, |:windo|, |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
353 |:ldo|, |:cfdo| and |:lfdo|. |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
354 |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
355 *:cfdo* |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
356 :cfdo[!] {cmd} Execute {cmd} in each file in the quickfix list. |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
357 It works like doing this: > |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
358 :cfirst |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
359 :{cmd} |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
360 :cnfile |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
361 :{cmd} |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
362 etc. |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
363 < Otherwise it works the same as `:cdo`. |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
364 {not in Vi} {not available when compiled without the |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
365 |+listcmds| feature} |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
366 |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
367 *:ldo* |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
368 :ld[o][!] {cmd} Execute {cmd} in each valid entry in the location list |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
369 for the current window. |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
370 It works like doing this: > |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
371 :lfirst |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
372 :{cmd} |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
373 :lnext |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
374 :{cmd} |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
375 etc. |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
376 < Only valid entries in the location list are used. |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
377 Otherwise it works the same as `:cdo`. |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
378 {not in Vi} {not available when compiled without the |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
379 |+listcmds| feature} |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
380 |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
381 *:lfdo* |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
382 :lfdo[!] {cmd} Execute {cmd} in each file in the location list for |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
383 the current window. |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
384 It works like doing this: > |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
385 :lfirst |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
386 :{cmd} |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
387 :lnfile |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
388 :{cmd} |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
389 etc. |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
390 < Otherwise it works the same as `:ldo`. |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
391 {not in Vi} {not available when compiled without the |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
392 |+listcmds| feature} |
f717d96a39b3
commit https://github.com/vim/vim/commit/12969c04fe7bd27dc0cbf37709eb40a86d4a27f9
Christian Brabandt <cb@256bit.org>
parents:
5763
diff
changeset
|
393 |
7 | 394 ============================================================================= |
395 2. The error window *quickfix-window* | |
396 | |
2411
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2365
diff
changeset
|
397 *:cope* *:copen* *w:quickfix_title* |
7 | 398 :cope[n] [height] Open a window to show the current list of errors. |
5763 | 399 |
7 | 400 When [height] is given, the window becomes that high |
5763 | 401 (if there is room). When [height] is omitted the |
402 window is made ten lines high. | |
403 | |
404 If there already is a quickfix window, it will be made | |
405 the current window. It is not possible to open a | |
406 second quickfix window. If [height] is given the | |
407 existing window will be resized to it. | |
408 | |
7 | 409 The window will contain a special buffer, with |
410 'buftype' equal to "quickfix". Don't change this! | |
5763 | 411 The window will have the w:quickfix_title variable set |
412 which will indicate the command that produced the | |
413 quickfix list. This can be used to compose a custom | |
414 status line if the value of 'statusline' is adjusted | |
415 properly. | |
7 | 416 |
647 | 417 *:lop* *:lopen* |
418 :lop[en] [height] Open a window to show the location list for the | |
644 | 419 current window. Works only when the location list for |
647 | 420 the current window is present. You can have more than |
421 one location window opened at a time. Otherwise, it | |
648 | 422 acts the same as ":copen". |
644 | 423 |
7 | 424 *:ccl* *:cclose* |
425 :ccl[ose] Close the quickfix window. | |
426 | |
644 | 427 *:lcl* *:lclose* |
428 :lcl[ose] Close the window showing the location list for the | |
429 current window. | |
430 | |
7 | 431 *:cw* *:cwindow* |
432 :cw[indow] [height] Open the quickfix window when there are recognized | |
433 errors. If the window is already open and there are | |
434 no recognized errors, close the window. | |
435 | |
644 | 436 *:lw* *:lwindow* |
437 :lw[indow] [height] Same as ":cwindow", except use the window showing the | |
438 location list for the current window. | |
7 | 439 |
9458
374afcf9d11d
commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents:
9432
diff
changeset
|
440 *:cbo* *:cbottom* |
9432
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9407
diff
changeset
|
441 :cbo[ttom] Put the cursor in the last line of the quickfix window |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9407
diff
changeset
|
442 and scroll to make it visible. This is useful for |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9407
diff
changeset
|
443 when errors are added by an asynchronous callback. |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9407
diff
changeset
|
444 Only call it once in a while if there are many |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9407
diff
changeset
|
445 updates to avoid a lot of redrawing. |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9407
diff
changeset
|
446 |
9458
374afcf9d11d
commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents:
9432
diff
changeset
|
447 *:lbo* *:lbottom* |
374afcf9d11d
commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents:
9432
diff
changeset
|
448 :lbo[ttom] Same as ":cbottom", except use the window showing the |
374afcf9d11d
commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents:
9432
diff
changeset
|
449 location list for the current window. |
374afcf9d11d
commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents:
9432
diff
changeset
|
450 |
7 | 451 Normally the quickfix window is at the bottom of the screen. If there are |
452 vertical splits, it's at the bottom of the rightmost column of windows. To | |
453 make it always occupy the full width: > | |
454 :botright cwindow | |
455 You can move the window around with |window-moving| commands. | |
456 For example, to move it to the top: CTRL-W K | |
457 The 'winfixheight' option will be set, which means that the window will mostly | |
458 keep its height, ignoring 'winheight' and 'equalalways'. You can change the | |
459 height manually (e.g., by dragging the status line above it with the mouse). | |
460 | |
461 In the quickfix window, each line is one error. The line number is equal to | |
462 the error number. You can use ":.cc" to jump to the error under the cursor. | |
170 | 463 Hitting the <Enter> key or double-clicking the mouse on a line has the same |
7 | 464 effect. The file containing the error is opened in the window above the |
465 quickfix window. If there already is a window for that file, it is used | |
466 instead. If the buffer in the used window has changed, and the error is in | |
467 another file, jumping to the error will fail. You will first have to make | |
468 sure the window contains a buffer which can be abandoned. | |
170 | 469 *CTRL-W_<Enter>* *CTRL-W_<CR>* |
470 You can use CTRL-W <Enter> to open a new window and jump to the error there. | |
7 | 471 |
472 When the quickfix window has been filled, two autocommand events are | |
473 triggered. First the 'filetype' option is set to "qf", which triggers the | |
651 | 474 FileType event. Then the BufReadPost event is triggered, using "quickfix" for |
475 the buffer name. This can be used to perform some action on the listed | |
476 errors. Example: > | |
648 | 477 au BufReadPost quickfix setlocal modifiable |
478 \ | silent exe 'g/^/s//\=line(".")." "/' | |
479 \ | setlocal nomodifiable | |
7 | 480 This prepends the line number to each line. Note the use of "\=" in the |
481 substitute string of the ":s" command, which is used to evaluate an | |
482 expression. | |
651 | 483 The BufWinEnter event is also triggered, again using "quickfix" for the buffer |
484 name. | |
7 | 485 |
9227
ecb621205ed1
commit https://github.com/vim/vim/commit/82af8710bf8d1caeeceafb1370a052cb7d92f076
Christian Brabandt <cb@256bit.org>
parents:
8702
diff
changeset
|
486 Note: When adding to an existing quickfix list the autocommand are not |
ecb621205ed1
commit https://github.com/vim/vim/commit/82af8710bf8d1caeeceafb1370a052cb7d92f076
Christian Brabandt <cb@256bit.org>
parents:
8702
diff
changeset
|
487 triggered. |
ecb621205ed1
commit https://github.com/vim/vim/commit/82af8710bf8d1caeeceafb1370a052cb7d92f076
Christian Brabandt <cb@256bit.org>
parents:
8702
diff
changeset
|
488 |
7 | 489 Note: Making changes in the quickfix window has no effect on the list of |
490 errors. 'modifiable' is off to avoid making changes. If you delete or insert | |
491 lines anyway, the relation between the text and the error number is messed up. | |
492 If you really want to do this, you could write the contents of the quickfix | |
493 window to a file and use ":cfile" to have it parsed and used as the new error | |
494 list. | |
495 | |
644 | 496 *location-list-window* |
648 | 497 The location list window displays the entries in a location list. When you |
498 open a location list window, it is created below the current window and | |
499 displays the location list for the current window. The location list window | |
500 is similar to the quickfix window, except that you can have more than one | |
651 | 501 location list window open at a time. When you use a location list command in |
502 this window, the displayed location list is used. | |
648 | 503 |
504 When you select a file from the location list window, the following steps are | |
505 used to find a window to edit the file: | |
644 | 506 |
648 | 507 1. If a window with the location list displayed in the location list window is |
508 present, then the file is opened in that window. | |
509 2. If the above step fails and if the file is already opened in another | |
510 window, then that window is used. | |
511 3. If the above step fails then an existing window showing a buffer with | |
512 'buftype' not set is used. | |
513 4. If the above step fails, then the file is edited in a new window. | |
514 | |
515 In all of the above cases, if the location list for the selected window is not | |
516 yet set, then it is set to the location list displayed in the location list | |
517 window. | |
644 | 518 |
7 | 519 ============================================================================= |
520 3. Using more than one list of errors *quickfix-error-lists* | |
521 | |
522 So far has been assumed that there is only one list of errors. Actually the | |
523 ten last used lists are remembered. When starting a new list, the previous | |
524 ones are automatically kept. Two commands can be used to access older error | |
525 lists. They set one of the existing error lists as the current one. | |
526 | |
527 *:colder* *:col* *E380* | |
528 :col[der] [count] Go to older error list. When [count] is given, do | |
529 this [count] times. When already at the oldest error | |
530 list, an error message is given. | |
531 | |
644 | 532 *:lolder* *:lol* |
9555
9560a5b782ee
commit https://github.com/vim/vim/commit/42ebd066422d73cdb7bda6a1dc828a3dd022dec8
Christian Brabandt <cb@256bit.org>
parents:
9458
diff
changeset
|
533 :lol[der] [count] Same as `:colder`, except use the location list for |
644 | 534 the current window instead of the quickfix list. |
535 | |
7 | 536 *:cnewer* *:cnew* *E381* |
537 :cnew[er] [count] Go to newer error list. When [count] is given, do | |
538 this [count] times. When already at the newest error | |
539 list, an error message is given. | |
540 | |
644 | 541 *:lnewer* *:lnew* |
9555
9560a5b782ee
commit https://github.com/vim/vim/commit/42ebd066422d73cdb7bda6a1dc828a3dd022dec8
Christian Brabandt <cb@256bit.org>
parents:
9458
diff
changeset
|
542 :lnew[er] [count] Same as `:cnewer`, except use the location list for |
644 | 543 the current window instead of the quickfix list. |
544 | |
9555
9560a5b782ee
commit https://github.com/vim/vim/commit/42ebd066422d73cdb7bda6a1dc828a3dd022dec8
Christian Brabandt <cb@256bit.org>
parents:
9458
diff
changeset
|
545 *:chistory* *:chi* |
9560a5b782ee
commit https://github.com/vim/vim/commit/42ebd066422d73cdb7bda6a1dc828a3dd022dec8
Christian Brabandt <cb@256bit.org>
parents:
9458
diff
changeset
|
546 :chi[story] Show the list of error lists. The current list is |
9560a5b782ee
commit https://github.com/vim/vim/commit/42ebd066422d73cdb7bda6a1dc828a3dd022dec8
Christian Brabandt <cb@256bit.org>
parents:
9458
diff
changeset
|
547 marked with ">". The output looks like: |
9560a5b782ee
commit https://github.com/vim/vim/commit/42ebd066422d73cdb7bda6a1dc828a3dd022dec8
Christian Brabandt <cb@256bit.org>
parents:
9458
diff
changeset
|
548 error list 1 of 3; 43 errors ~ |
9560a5b782ee
commit https://github.com/vim/vim/commit/42ebd066422d73cdb7bda6a1dc828a3dd022dec8
Christian Brabandt <cb@256bit.org>
parents:
9458
diff
changeset
|
549 > error list 2 of 3; 0 errors ~ |
9560a5b782ee
commit https://github.com/vim/vim/commit/42ebd066422d73cdb7bda6a1dc828a3dd022dec8
Christian Brabandt <cb@256bit.org>
parents:
9458
diff
changeset
|
550 error list 3 of 3; 15 errors ~ |
9560a5b782ee
commit https://github.com/vim/vim/commit/42ebd066422d73cdb7bda6a1dc828a3dd022dec8
Christian Brabandt <cb@256bit.org>
parents:
9458
diff
changeset
|
551 |
9560a5b782ee
commit https://github.com/vim/vim/commit/42ebd066422d73cdb7bda6a1dc828a3dd022dec8
Christian Brabandt <cb@256bit.org>
parents:
9458
diff
changeset
|
552 *:lhistory* *:lhi* |
9560a5b782ee
commit https://github.com/vim/vim/commit/42ebd066422d73cdb7bda6a1dc828a3dd022dec8
Christian Brabandt <cb@256bit.org>
parents:
9458
diff
changeset
|
553 :lhi[story] Show the list of location lists, otherwise like |
9560a5b782ee
commit https://github.com/vim/vim/commit/42ebd066422d73cdb7bda6a1dc828a3dd022dec8
Christian Brabandt <cb@256bit.org>
parents:
9458
diff
changeset
|
554 `:chistory`. |
9560a5b782ee
commit https://github.com/vim/vim/commit/42ebd066422d73cdb7bda6a1dc828a3dd022dec8
Christian Brabandt <cb@256bit.org>
parents:
9458
diff
changeset
|
555 |
7 | 556 When adding a new error list, it becomes the current list. |
557 | |
558 When ":colder" has been used and ":make" or ":grep" is used to add a new error | |
559 list, one newer list is overwritten. This is especially useful if you are | |
560 browsing with ":grep" |grep|. If you want to keep the more recent error | |
561 lists, use ":cnewer 99" first. | |
562 | |
563 ============================================================================= | |
564 4. Using :make *:make_makeprg* | |
565 | |
566 *:mak* *:make* | |
163 | 567 :mak[e][!] [arguments] 1. If vim was built with |+autocmd|, all relevant |
568 |QuickFixCmdPre| autocommands are executed. | |
569 2. If the 'autowrite' option is on, write any changed | |
7 | 570 buffers |
163 | 571 3. An errorfile name is made from 'makeef'. If |
7 | 572 'makeef' doesn't contain "##", and a file with this |
573 name already exists, it is deleted. | |
163 | 574 4. The program given with the 'makeprg' option is |
7 | 575 started (default "make") with the optional |
576 [arguments] and the output is saved in the | |
577 errorfile (for Unix it is also echoed on the | |
578 screen). | |
163 | 579 5. The errorfile is read using 'errorformat'. |
1167 | 580 6. If vim was built with |+autocmd|, all relevant |
163 | 581 |QuickFixCmdPost| autocommands are executed. |
1624 | 582 See example below. |
1167 | 583 7. If [!] is not given the first error is jumped to. |
584 8. The errorfile is deleted. | |
163 | 585 9. You can now move through the errors with commands |
7 | 586 like |:cnext| and |:cprevious|, see above. |
587 This command does not accept a comment, any " | |
588 characters are considered part of the arguments. | |
589 | |
658 | 590 *:lmak* *:lmake* |
591 :lmak[e][!] [arguments] | |
592 Same as ":make", except the location list for the | |
593 current window is used instead of the quickfix list. | |
594 | |
7 | 595 The ":make" command executes the command given with the 'makeprg' option. |
596 This is done by passing the command to the shell given with the 'shell' | |
597 option. This works almost like typing | |
598 | |
599 ":!{makeprg} [arguments] {shellpipe} {errorfile}". | |
600 | |
601 {makeprg} is the string given with the 'makeprg' option. Any command can be | |
602 used, not just "make". Characters '%' and '#' are expanded as usual on a | |
603 command-line. You can use "%<" to insert the current file name without | |
604 extension, or "#<" to insert the alternate file name without extension, for | |
605 example: > | |
606 :set makeprg=make\ #<.o | |
607 | |
608 [arguments] is anything that is typed after ":make". | |
609 {shellpipe} is the 'shellpipe' option. | |
610 {errorfile} is the 'makeef' option, with ## replaced to make it unique. | |
611 | |
2072 | 612 The placeholder "$*" can be used for the argument list in {makeprg} if the |
7 | 613 command needs some additional characters after its arguments. The $* is |
614 replaced then by all arguments. Example: > | |
615 :set makeprg=latex\ \\\\nonstopmode\ \\\\input\\{$*} | |
616 or simpler > | |
617 :let &mp = 'latex \\nonstopmode \\input\{$*}' | |
618 "$*" can be given multiple times, for example: > | |
619 :set makeprg=gcc\ -o\ $*\ $* | |
620 | |
621 The 'shellpipe' option defaults to ">" for the Amiga, MS-DOS and Win32. This | |
622 means that the output of the compiler is saved in a file and not shown on the | |
623 screen directly. For Unix "| tee" is used. The compiler output is shown on | |
624 the screen and saved in a file the same time. Depending on the shell used | |
625 "|& tee" or "2>&1| tee" is the default, so stderr output will be included. | |
626 | |
627 If 'shellpipe' is empty, the {errorfile} part will be omitted. This is useful | |
628 for compilers that write to an errorfile themselves (e.g., Manx's Amiga C). | |
629 | |
1624 | 630 |
631 Using QuickFixCmdPost to fix the encoding ~ | |
632 | |
633 It may be that 'encoding' is set to an encoding that differs from the messages | |
634 your build program produces. This example shows how to fix this after Vim has | |
635 read the error messages: > | |
636 | |
637 function QfMakeConv() | |
638 let qflist = getqflist() | |
639 for i in qflist | |
640 let i.text = iconv(i.text, "cp936", "utf-8") | |
641 endfor | |
642 call setqflist(qflist) | |
643 endfunction | |
644 | |
645 au QuickfixCmdPost make call QfMakeConv() | |
646 | |
647 (Example by Faque Cheng) | |
648 | |
7 | 649 ============================================================================== |
41 | 650 5. Using :vimgrep and :grep *grep* *lid* |
651 | |
652 Vim has two ways to find matches for a pattern: Internal and external. The | |
653 advantage of the internal grep is that it works on all systems and uses the | |
654 powerful Vim search patterns. An external grep program can be used when the | |
655 Vim grep does not do what you want. | |
656 | |
43 | 657 The internal method will be slower, because files are read into memory. The |
658 advantages are: | |
659 - Line separators and encoding are automatically recognized, as if a file is | |
660 being edited. | |
661 - Uses Vim search patterns. Multi-line patterns can be used. | |
662 - When plugins are enabled: compressed and remote files can be searched. | |
663 |gzip| |netrw| | |
717 | 664 |
665 To be able to do this Vim loads each file as if it is being edited. When | |
720 | 666 there is no match in the file the associated buffer is wiped out again. The |
717 | 667 'hidden' option is ignored here to avoid running out of memory or file |
668 descriptors when searching many files. However, when the |:hide| command | |
669 modifier is used the buffers are kept loaded. This makes following searches | |
670 in the same files a lot faster. | |
41 | 671 |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2577
diff
changeset
|
672 Note that |:copen| (or |:lopen| for |:lgrep|) may be used to open a buffer |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2577
diff
changeset
|
673 containing the search results in linked form. The |:silent| command may be |
2698
b6471224d2af
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2608
diff
changeset
|
674 used to suppress the default full screen grep output. The ":grep!" form of |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2577
diff
changeset
|
675 the |:grep| command doesn't jump to the first match automatically. These |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2577
diff
changeset
|
676 commands can be combined to create a NewGrep command: > |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2577
diff
changeset
|
677 |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2577
diff
changeset
|
678 command! -nargs=+ NewGrep execute 'silent grep! <args>' | copen 42 |
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2577
diff
changeset
|
679 |
41 | 680 |
681 5.1 using Vim's internal grep | |
682 | |
86 | 683 *:vim* *:vimgrep* *E682* *E683* |
170 | 684 :vim[grep][!] /{pattern}/[g][j] {file} ... |
41 | 685 Search for {pattern} in the files {file} ... and set |
3682 | 686 the error list to the matches. Files matching |
687 'wildignore' are ignored; files in 'suffixes' are | |
688 searched last. | |
170 | 689 Without the 'g' flag each line is added only once. |
690 With 'g' every match is added. | |
691 | |
692 {pattern} is a Vim search pattern. Instead of | |
693 enclosing it in / any non-ID character (see | |
694 |'isident'|) can be used, so long as it does not | |
695 appear in {pattern}. | |
696 'ignorecase' applies. To overrule it put |/\c| in the | |
697 pattern to ignore case or |/\C| to match case. | |
698 'smartcase' is not used. | |
4197 | 699 If {pattern} is empty (e.g. // is specified), the last |
700 used search pattern is used. |last-pattern| | |
170 | 701 |
716 | 702 When a number is put before the command this is used |
703 as the maximum number of matches to find. Use | |
704 ":1vimgrep pattern file" to find only the first. | |
705 Useful if you only want to check if there is a match | |
706 and quit quickly when it's found. | |
707 | |
170 | 708 Without the 'j' flag Vim jumps to the first match. |
709 With 'j' only the quickfix list is updated. | |
710 With the [!] any changes in the current buffer are | |
711 abandoned. | |
712 | |
123 | 713 Every second or so the searched file name is displayed |
714 to give you an idea of the progress made. | |
43 | 715 Examples: > |
716 :vimgrep /an error/ *.c | |
717 :vimgrep /\<FileName\>/ *.h include/* | |
445 | 718 :vimgrep /myfunc/ **/*.c |
719 < For the use of "**" see |starstar-wildcard|. | |
41 | 720 |
43 | 721 :vim[grep][!] {pattern} {file} ... |
722 Like above, but instead of enclosing the pattern in a | |
723 non-ID character use a white-separated pattern. The | |
724 pattern must start with an ID character. | |
725 Example: > | |
726 :vimgrep Error *.c | |
727 < | |
658 | 728 *:lv* *:lvimgrep* |
729 :lv[imgrep][!] /{pattern}/[g][j] {file} ... | |
730 :lv[imgrep][!] {pattern} {file} ... | |
731 Same as ":vimgrep", except the location list for the | |
732 current window is used instead of the quickfix list. | |
733 | |
41 | 734 *:vimgrepa* *:vimgrepadd* |
170 | 735 :vimgrepa[dd][!] /{pattern}/[g][j] {file} ... |
736 :vimgrepa[dd][!] {pattern} {file} ... | |
41 | 737 Just like ":vimgrep", but instead of making a new list |
738 of errors the matches are appended to the current | |
739 list. | |
740 | |
658 | 741 *:lvimgrepa* *:lvimgrepadd* |
742 :lvimgrepa[dd][!] /{pattern}/[g][j] {file} ... | |
743 :lvimgrepa[dd][!] {pattern} {file} ... | |
744 Same as ":vimgrepadd", except the location list for | |
745 the current window is used instead of the quickfix | |
746 list. | |
41 | 747 |
748 5.2 External grep | |
7 | 749 |
750 Vim can interface with "grep" and grep-like programs (such as the GNU | |
751 id-utils) in a similar way to its compiler integration (see |:make| above). | |
752 | |
753 [Unix trivia: The name for the Unix "grep" command comes from ":g/re/p", where | |
754 "re" stands for Regular Expression.] | |
755 | |
756 *:gr* *:grep* | |
757 :gr[ep][!] [arguments] Just like ":make", but use 'grepprg' instead of | |
758 'makeprg' and 'grepformat' instead of 'errorformat'. | |
41 | 759 When 'grepprg' is "internal" this works like |
760 |:vimgrep|. Note that the pattern needs to be | |
761 enclosed in separator characters then. | |
658 | 762 |
763 *:lgr* *:lgrep* | |
764 :lgr[ep][!] [arguments] Same as ":grep", except the location list for the | |
765 current window is used instead of the quickfix list. | |
766 | |
7 | 767 *:grepa* *:grepadd* |
768 :grepa[dd][!] [arguments] | |
769 Just like ":grep", but instead of making a new list of | |
770 errors the matches are appended to the current list. | |
771 Example: > | |
2033
de5a43c5eedc
Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
1702
diff
changeset
|
772 :call setqflist([]) |
7 | 773 :bufdo grepadd! something % |
774 < The first command makes a new error list which is | |
775 empty. The second command executes "grepadd" for each | |
776 listed buffer. Note the use of ! to avoid that | |
777 ":grepadd" jumps to the first error, which is not | |
778 allowed with |:bufdo|. | |
2033
de5a43c5eedc
Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
1702
diff
changeset
|
779 An example that uses the argument list and avoids |
de5a43c5eedc
Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
1702
diff
changeset
|
780 errors for files without matches: > |
de5a43c5eedc
Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
1702
diff
changeset
|
781 :silent argdo try |
de5a43c5eedc
Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
1702
diff
changeset
|
782 \ | grepadd! something % |
de5a43c5eedc
Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
1702
diff
changeset
|
783 \ | catch /E480:/ |
de5a43c5eedc
Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
1702
diff
changeset
|
784 \ | endtry" |
de5a43c5eedc
Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
1702
diff
changeset
|
785 < |
658 | 786 *:lgrepa* *:lgrepadd* |
787 :lgrepa[dd][!] [arguments] | |
788 Same as ":grepadd", except the location list for the | |
789 current window is used instead of the quickfix list. | |
790 | |
41 | 791 5.3 Setting up external grep |
7 | 792 |
793 If you have a standard "grep" program installed, the :grep command may work | |
237 | 794 well with the defaults. The syntax is very similar to the standard command: > |
7 | 795 |
796 :grep foo *.c | |
797 | |
237 | 798 Will search all files with the .c extension for the substring "foo". The |
7 | 799 arguments to :grep are passed straight to the "grep" program, so you can use |
800 whatever options your "grep" supports. | |
801 | |
802 By default, :grep invokes grep with the -n option (show file and line | |
237 | 803 numbers). You can change this with the 'grepprg' option. You will need to set |
7 | 804 'grepprg' if: |
805 | |
806 a) You are using a program that isn't called "grep" | |
807 b) You have to call grep with a full path | |
808 c) You want to pass other options automatically (e.g. case insensitive | |
809 search.) | |
810 | |
811 Once "grep" has executed, Vim parses the results using the 'grepformat' | |
812 option. This option works in the same way as the 'errorformat' option - see | |
813 that for details. You may need to change 'grepformat' from the default if | |
814 your grep outputs in a non-standard format, or you are using some other | |
815 program with a special format. | |
816 | |
817 Once the results are parsed, Vim loads the first file containing a match and | |
818 jumps to the appropriate line, in the same way that it jumps to a compiler | |
819 error in |quickfix| mode. You can then use the |:cnext|, |:clist|, etc. | |
820 commands to see the other matches. | |
821 | |
822 | |
41 | 823 5.4 Using :grep with id-utils |
7 | 824 |
825 You can set up :grep to work with the GNU id-utils like this: > | |
826 | |
827 :set grepprg=lid\ -Rgrep\ -s | |
828 :set grepformat=%f:%l:%m | |
829 | |
830 then > | |
831 :grep (regexp) | |
832 | |
833 works just as you'd expect. | |
834 (provided you remembered to mkid first :) | |
835 | |
836 | |
41 | 837 5.5 Browsing source code with :vimgrep or :grep |
7 | 838 |
839 Using the stack of error lists that Vim keeps, you can browse your files to | |
840 look for functions and the functions they call. For example, suppose that you | |
841 have to add an argument to the read_file() function. You enter this command: > | |
842 | |
41 | 843 :vimgrep /\<read_file\>/ *.c |
7 | 844 |
845 You use ":cn" to go along the list of matches and add the argument. At one | |
846 place you have to get the new argument from a higher level function msg(), and | |
847 need to change that one too. Thus you use: > | |
848 | |
41 | 849 :vimgrep /\<msg\>/ *.c |
7 | 850 |
851 While changing the msg() functions, you find another function that needs to | |
41 | 852 get the argument from a higher level. You can again use ":vimgrep" to find |
853 these functions. Once you are finished with one function, you can use > | |
7 | 854 |
855 :colder | |
856 | |
857 to go back to the previous one. | |
858 | |
41 | 859 This works like browsing a tree: ":vimgrep" goes one level deeper, creating a |
7 | 860 list of branches. ":colder" goes back to the previous level. You can mix |
41 | 861 this use of ":vimgrep" and "colder" to browse all the locations in a tree-like |
7 | 862 way. If you do this consistently, you will find all locations without the |
863 need to write down a "todo" list. | |
864 | |
865 ============================================================================= | |
866 6. Selecting a compiler *compiler-select* | |
867 | |
868 *:comp* *:compiler* *E666* | |
869 :comp[iler][!] {name} Set options to work with compiler {name}. | |
870 Without the "!" options are set for the | |
871 current buffer. With "!" global options are | |
872 set. | |
873 If you use ":compiler foo" in "file.foo" and | |
874 then ":compiler! bar" in another buffer, Vim | |
875 will keep on using "foo" in "file.foo". | |
876 {not available when compiled without the | |
877 |+eval| feature} | |
878 | |
879 | |
880 The Vim plugins in the "compiler" directory will set options to use the | |
10348
c78513465e6e
commit https://github.com/vim/vim/commit/25de4c232d580583feadae11ab34e3cc6333c350
Christian Brabandt <cb@256bit.org>
parents:
10198
diff
changeset
|
881 selected compiler. For `:compiler` local options are set, for `:compiler!` |
7 | 882 global options. |
883 *current_compiler* | |
884 To support older Vim versions, the plugins always use "current_compiler" and | |
885 not "b:current_compiler". What the command actually does is the following: | |
886 | |
887 - Delete the "current_compiler" and "b:current_compiler" variables. | |
888 - Define the "CompilerSet" user command. With "!" it does ":set", without "!" | |
889 it does ":setlocal". | |
890 - Execute ":runtime! compiler/{name}.vim". The plugins are expected to set | |
891 options with "CompilerSet" and set the "current_compiler" variable to the | |
892 name of the compiler. | |
170 | 893 - Delete the "CompilerSet" user command. |
7 | 894 - Set "b:current_compiler" to the value of "current_compiler". |
895 - Without "!" the old value of "current_compiler" is restored. | |
896 | |
897 | |
898 For writing a compiler plugin, see |write-compiler-plugin|. | |
899 | |
900 | |
1228 | 901 GCC *quickfix-gcc* *compiler-gcc* |
902 | |
903 There's one variable you can set for the GCC compiler: | |
904 | |
905 g:compiler_gcc_ignore_unmatched_lines | |
906 Ignore lines that don't match any patterns | |
907 defined for GCC. Useful if output from | |
908 commands run from make are generating false | |
909 positives. | |
910 | |
911 | |
7 | 912 MANX AZTEC C *quickfix-manx* *compiler-manx* |
913 | |
914 To use Vim with Manx's Aztec C compiler on the Amiga you should do the | |
915 following: | |
916 - Set the CCEDIT environment variable with the command: > | |
917 mset "CCEDIT=vim -q" | |
918 - Compile with the -qf option. If the compiler finds any errors, Vim is | |
919 started and the cursor is positioned on the first error. The error message | |
920 will be displayed on the last line. You can go to other errors with the | |
921 commands mentioned above. You can fix the errors and write the file(s). | |
922 - If you exit Vim normally the compiler will re-compile the same file. If you | |
923 exit with the :cq command, the compiler will terminate. Do this if you | |
924 cannot fix the error, or if another file needs to be compiled first. | |
925 | |
926 There are some restrictions to the Quickfix mode on the Amiga. The | |
927 compiler only writes the first 25 errors to the errorfile (Manx's | |
928 documentation does not say how to get more). If you want to find the others, | |
929 you will have to fix a few errors and exit the editor. After recompiling, | |
930 up to 25 remaining errors will be found. | |
931 | |
932 If Vim was started from the compiler, the :sh and some :! commands will not | |
933 work, because Vim is then running in the same process as the compiler and | |
934 stdin (standard input) will not be interactive. | |
935 | |
936 | |
1624 | 937 PERL *quickfix-perl* *compiler-perl* |
938 | |
939 The Perl compiler plugin doesn't actually compile, but invokes Perl's internal | |
940 syntax checking feature and parses the output for possible errors so you can | |
941 correct them in quick-fix mode. | |
942 | |
943 Warnings are forced regardless of "no warnings" or "$^W = 0" within the file | |
944 being checked. To disable this set g:perl_compiler_force_warnings to a zero | |
945 value. For example: > | |
946 let g:perl_compiler_force_warnings = 0 | |
947 | |
948 | |
7 | 949 PYUNIT COMPILER *compiler-pyunit* |
950 | |
951 This is not actually a compiler, but a unit testing framework for the | |
237 | 952 Python language. It is included into standard Python distribution |
953 starting from version 2.0. For older versions, you can get it from | |
7 | 954 http://pyunit.sourceforge.net. |
955 | |
956 When you run your tests with the help of the framework, possible errors | |
957 are parsed by Vim and presented for you in quick-fix mode. | |
958 | |
959 Unfortunately, there is no standard way to run the tests. | |
960 The alltests.py script seems to be used quite often, that's all. | |
961 Useful values for the 'makeprg' options therefore are: | |
962 setlocal makeprg=./alltests.py " Run a testsuite | |
5690 | 963 setlocal makeprg=python\ %:S " Run a single testcase |
7 | 964 |
965 Also see http://vim.sourceforge.net/tip_view.php?tip_id=280. | |
966 | |
967 | |
968 TEX COMPILER *compiler-tex* | |
969 | |
970 Included in the distribution compiler for TeX ($VIMRUNTIME/compiler/tex.vim) | |
237 | 971 uses make command if possible. If the compiler finds a file named "Makefile" |
7 | 972 or "makefile" in the current directory, it supposes that you want to process |
237 | 973 your *TeX files with make, and the makefile does the right work. In this case |
974 compiler sets 'errorformat' for *TeX output and leaves 'makeprg' untouched. If | |
7 | 975 neither "Makefile" nor "makefile" is found, the compiler will not use make. |
976 You can force the compiler to ignore makefiles by defining | |
977 b:tex_ignore_makefile or g:tex_ignore_makefile variable (they are checked for | |
978 existence only). | |
979 | |
980 If the compiler chose not to use make, it need to choose a right program for | |
237 | 981 processing your input. If b:tex_flavor or g:tex_flavor (in this precedence) |
7 | 982 variable exists, it defines TeX flavor for :make (actually, this is the name |
983 of executed command), and if both variables do not exist, it defaults to | |
237 | 984 "latex". For example, while editing chapter2.tex \input-ed from mypaper.tex |
7 | 985 written in AMS-TeX: > |
986 | |
987 :let b:tex_flavor = 'amstex' | |
988 :compiler tex | |
989 < [editing...] > | |
990 :make mypaper | |
991 | |
992 Note that you must specify a name of the file to process as an argument (to | |
993 process the right file when editing \input-ed or \include-ed file; portable | |
237 | 994 solution for substituting % for no arguments is welcome). This is not in the |
7 | 995 semantics of make, where you specify a target, not source, but you may specify |
996 filename without extension ".tex" and mean this as "make filename.dvi or | |
997 filename.pdf or filename.some_result_extension according to compiler". | |
998 | |
999 Note: tex command line syntax is set to usable both for MikTeX (suggestion | |
237 | 1000 by Srinath Avadhanula) and teTeX (checked by Artem Chuprina). Suggestion |
7 | 1001 from |errorformat-LaTeX| is too complex to keep it working for different |
1002 shells and OSes and also does not allow to use other available TeX options, | |
237 | 1003 if any. If your TeX doesn't support "-interaction=nonstopmode", please |
7 | 1004 report it with different means to express \nonstopmode from the command line. |
1005 | |
1006 ============================================================================= | |
1007 7. The error format *error-file-format* | |
1008 | |
1009 *errorformat* *E372* *E373* *E374* | |
1010 *E375* *E376* *E377* *E378* | |
1011 The 'errorformat' option specifies a list of formats that are recognized. The | |
1012 first format that matches with an error message is used. You can add several | |
1013 formats for different messages your compiler produces, or even entries for | |
1014 multiple compilers. See |efm-entries|. | |
1015 | |
1016 Each entry in 'errorformat' is a scanf-like string that describes the format. | |
1017 First, you need to know how scanf works. Look in the documentation of your | |
1018 C compiler. Below you find the % items that Vim understands. Others are | |
1019 invalid. | |
1020 | |
1021 Special characters in 'errorformat' are comma and backslash. See | |
1022 |efm-entries| for how to deal with them. Note that a literal "%" is matched | |
1023 by "%%", thus it is not escaped with a backslash. | |
5277 | 1024 Keep in mind that in the `:make` and `:grep` output all NUL characters are |
1025 replaced with SOH (0x01). | |
7 | 1026 |
1027 Note: By default the difference between upper and lowercase is ignored. If | |
1028 you want to match case, add "\C" to the pattern |/\C|. | |
1029 | |
1030 | |
1031 Basic items | |
1032 | |
1033 %f file name (finds a string) | |
1034 %l line number (finds a number) | |
1035 %c column number (finds a number representing character | |
1036 column of the error, (1 <tab> == 1 character column)) | |
1037 %v virtual column number (finds a number representing | |
1038 screen column of the error (1 <tab> == 8 screen | |
237 | 1039 columns)) |
7 | 1040 %t error type (finds a single character) |
1041 %n error number (finds a number) | |
1042 %m error message (finds a string) | |
1043 %r matches the "rest" of a single-line file message %O/P/Q | |
3557 | 1044 %p pointer line (finds a sequence of '-', '.', ' ' or |
1045 tabs and uses the length for the column number) | |
7 | 1046 %*{conv} any scanf non-assignable conversion |
1047 %% the single '%' character | |
231 | 1048 %s search text (finds a string) |
7 | 1049 |
502 | 1050 The "%f" conversion may depend on the current 'isfname' setting. "~/" is |
279 | 1051 expanded to the home directory and environment variables are expanded. |
7 | 1052 |
502 | 1053 The "%f" and "%m" conversions have to detect the end of the string. This |
534 | 1054 normally happens by matching following characters and items. When nothing is |
502 | 1055 following the rest of the line is matched. If "%f" is followed by a '%' or a |
1056 backslash, it will look for a sequence of 'isfname' characters. | |
7 | 1057 |
1058 On MS-DOS, MS-Windows and OS/2 a leading "C:" will be included in "%f", even | |
1059 when using "%f:". This means that a file name which is a single alphabetical | |
1060 letter will not be detected. | |
1061 | |
1062 The "%p" conversion is normally followed by a "^". It's used for compilers | |
1063 that output a line like: > | |
1064 ^ | |
1065 or > | |
1066 ---------^ | |
1067 to indicate the column of the error. This is to be used in a multi-line error | |
1068 message. See |errorformat-javac| for a useful example. | |
1069 | |
231 | 1070 The "%s" conversion specifies the text to search for to locate the error line. |
1071 The text is used as a literal string. The anchors "^" and "$" are added to | |
1072 the text to locate the error line exactly matching the search text and the | |
1073 text is prefixed with the "\V" atom to make it "very nomagic". The "%s" | |
1074 conversion can be used to locate lines without a line number in the error | |
1075 output. Like the output of the "grep" shell command. | |
1076 When the pattern is present the line number will not be used. | |
7 | 1077 |
1078 Changing directory | |
1079 | |
1080 The following uppercase conversion characters specify the type of special | |
1081 format strings. At most one of them may be given as a prefix at the begin | |
1082 of a single comma-separated format pattern. | |
1083 Some compilers produce messages that consist of directory names that have to | |
237 | 1084 be prepended to each file name read by %f (example: GNU make). The following |
7 | 1085 codes can be used to scan these directory names; they will be stored in an |
1086 internal directory stack. *E379* | |
1087 %D "enter directory" format string; expects a following | |
1088 %f that finds the directory name | |
1089 %X "leave directory" format string; expects following %f | |
1090 | |
1091 When defining an "enter directory" or "leave directory" format, the "%D" or | |
237 | 1092 "%X" has to be given at the start of that substring. Vim tracks the directory |
7 | 1093 changes and prepends the current directory to each erroneous file found with a |
1094 relative path. See |quickfix-directory-stack| for details, tips and | |
1095 limitations. | |
1096 | |
1097 | |
1098 Multi-line messages *errorformat-multi-line* | |
1099 | |
1100 It is possible to read the output of programs that produce multi-line | |
237 | 1101 messages, i.e. error strings that consume more than one line. Possible |
7 | 1102 prefixes are: |
1103 %E start of a multi-line error message | |
1104 %W start of a multi-line warning message | |
1105 %I start of a multi-line informational message | |
1106 %A start of a multi-line message (unspecified type) | |
791 | 1107 %> for next line start with current pattern again |efm-%>| |
7 | 1108 %C continuation of a multi-line message |
1109 %Z end of a multi-line message | |
1110 These can be used with '+' and '-', see |efm-ignore| below. | |
1111 | |
787 | 1112 Using "\n" in the pattern won't work to match multi-line messages. |
1113 | |
7 | 1114 Example: Your compiler happens to write out errors in the following format |
1115 (leading line numbers not being part of the actual output): | |
1116 | |
787 | 1117 1 Error 275 ~ |
1118 2 line 42 ~ | |
1119 3 column 3 ~ | |
1120 4 ' ' expected after '--' ~ | |
7 | 1121 |
1122 The appropriate error format string has to look like this: > | |
1123 :set efm=%EError\ %n,%Cline\ %l,%Ccolumn\ %c,%Z%m | |
1124 | |
1125 And the |:clist| error message generated for this error is: | |
1126 | |
1127 1:42 col 3 error 275: ' ' expected after '--' | |
1128 | |
1129 Another example: Think of a Python interpreter that produces the following | |
1130 error message (line numbers are not part of the actual output): | |
1131 | |
1132 1 ============================================================== | |
1133 2 FAIL: testGetTypeIdCachesResult (dbfacadeTest.DjsDBFacadeTest) | |
1134 3 -------------------------------------------------------------- | |
1135 4 Traceback (most recent call last): | |
1136 5 File "unittests/dbfacadeTest.py", line 89, in testFoo | |
1137 6 self.assertEquals(34, dtid) | |
1138 7 File "/usr/lib/python2.2/unittest.py", line 286, in | |
1139 8 failUnlessEqual | |
1140 9 raise self.failureException, \ | |
1141 10 AssertionError: 34 != 33 | |
1142 11 | |
1143 12 -------------------------------------------------------------- | |
1144 13 Ran 27 tests in 0.063s | |
1145 | |
1146 Say you want |:clist| write the relevant information of this message only, | |
1147 namely: | |
1148 5 unittests/dbfacadeTest.py:89: AssertionError: 34 != 33 | |
1149 | |
1150 Then the error format string could be defined as follows: > | |
1151 :set efm=%C\ %.%#,%A\ \ File\ \"%f\"\\,\ line\ %l%.%#,%Z%[%^\ ]%\\@=%m | |
1152 | |
1153 Note that the %C string is given before the %A here: since the expression | |
1154 ' %.%#' (which stands for the regular expression ' .*') matches every line | |
1155 starting with a space, followed by any characters to the end of the line, | |
1156 it also hides line 7 which would trigger a separate error message otherwise. | |
1157 Error format strings are always parsed pattern by pattern until the first | |
1158 match occurs. | |
791 | 1159 *efm-%>* |
1160 The %> item can be used to avoid trying patterns that appear earlier in | |
1161 'errorformat'. This is useful for patterns that match just about anything. | |
1162 For example, if the error looks like this: | |
1163 | |
1164 Error in line 123 of foo.c: ~ | |
1165 unknown variable "i" ~ | |
1166 | |
1167 This can be found with: > | |
1168 :set efm=xxx,%E%>Error in line %l of %f:,%Z%m | |
1169 Where "xxx" has a pattern that would also match the second line. | |
7 | 1170 |
787 | 1171 Important: There is no memory of what part of the errorformat matched before; |
1172 every line in the error file gets a complete new run through the error format | |
1173 lines. For example, if one has: > | |
1174 setlocal efm=aa,bb,cc,dd,ee | |
1175 Where aa, bb, etc. are error format strings. Each line of the error file will | |
1176 be matched to the pattern aa, then bb, then cc, etc. Just because cc matched | |
1177 the previous error line does _not_ mean that dd will be tried first on the | |
1178 current line, even if cc and dd are multi-line errorformat strings. | |
1179 | |
1180 | |
7 | 1181 |
1182 Separate file name *errorformat-separate-filename* | |
1183 | |
1184 These prefixes are useful if the file name is given once and multiple messages | |
1185 follow that refer to this file name. | |
1186 %O single-line file message: overread the matched part | |
1187 %P single-line file message: push file %f onto the stack | |
1188 %Q single-line file message: pop the last file from stack | |
1189 | |
1190 Example: Given a compiler that produces the following error logfile (without | |
1191 leading line numbers): | |
1192 | |
1193 1 [a1.tt] | |
1194 2 (1,17) error: ';' missing | |
1195 3 (21,2) warning: variable 'z' not defined | |
1196 4 (67,3) error: end of file found before string ended | |
1197 5 | |
1198 6 [a2.tt] | |
1199 7 | |
1200 8 [a3.tt] | |
1201 9 NEW compiler v1.1 | |
1202 10 (2,2) warning: variable 'x' not defined | |
1203 11 (67,3) warning: 's' already defined | |
1204 | |
1205 This logfile lists several messages for each file enclosed in [...] which are | |
1206 properly parsed by an error format like this: > | |
1207 :set efm=%+P[%f],(%l\\,%c)%*[\ ]%t%*[^:]:\ %m,%-Q | |
1208 | |
1209 A call of |:clist| writes them accordingly with their correct filenames: | |
1210 | |
1211 2 a1.tt:1 col 17 error: ';' missing | |
1212 3 a1.tt:21 col 2 warning: variable 'z' not defined | |
1213 4 a1.tt:67 col 3 error: end of file found before string ended | |
1214 8 a3.tt:2 col 2 warning: variable 'x' not defined | |
1215 9 a3.tt:67 col 3 warning: 's' already defined | |
1216 | |
1217 Unlike the other prefixes that all match against whole lines, %P, %Q and %O | |
237 | 1218 can be used to match several patterns in the same line. Thus it is possible |
7 | 1219 to parse even nested files like in the following line: |
1220 {"file1" {"file2" error1} error2 {"file3" error3 {"file4" error4 error5}}} | |
1221 The %O then parses over strings that do not contain any push/pop file name | |
1222 information. See |errorformat-LaTeX| for an extended example. | |
1223 | |
1224 | |
1225 Ignoring and using whole messages *efm-ignore* | |
1226 | |
1227 The codes '+' or '-' can be combined with the uppercase codes above; in that | |
237 | 1228 case they have to precede the letter, e.g. '%+A' or '%-G': |
7 | 1229 %- do not include the matching multi-line in any output |
1230 %+ include the whole matching line in the %m error string | |
1231 | |
237 | 1232 One prefix is only useful in combination with '+' or '-', namely %G. It parses |
7 | 1233 over lines containing general information like compiler version strings or |
1234 other headers that can be skipped. | |
1235 %-G ignore this message | |
1236 %+G general message | |
1237 | |
1238 | |
1239 Pattern matching | |
1240 | |
1241 The scanf()-like "%*[]" notation is supported for backward-compatibility | |
1242 with previous versions of Vim. However, it is also possible to specify | |
1243 (nearly) any Vim supported regular expression in format strings. | |
1244 Since meta characters of the regular expression language can be part of | |
1245 ordinary matching strings or file names (and therefore internally have to | |
1246 be escaped), meta symbols have to be written with leading '%': | |
787 | 1247 %\ The single '\' character. Note that this has to be |
7 | 1248 escaped ("%\\") in ":set errorformat=" definitions. |
787 | 1249 %. The single '.' character. |
1250 %# The single '*'(!) character. | |
1251 %^ The single '^' character. Note that this is not | |
1252 useful, the pattern already matches start of line. | |
1253 %$ The single '$' character. Note that this is not | |
1254 useful, the pattern already matches end of line. | |
1255 %[ The single '[' character for a [] character range. | |
1256 %~ The single '~' character. | |
7 | 1257 When using character classes in expressions (see |/\i| for an overview), |
1258 terms containing the "\+" quantifier can be written in the scanf() "%*" | |
237 | 1259 notation. Example: "%\\d%\\+" ("\d\+", "any number") is equivalent to "%*\\d". |
7 | 1260 Important note: The \(...\) grouping of sub-matches can not be used in format |
1261 specifications because it is reserved for internal conversions. | |
1262 | |
1263 | |
1264 Multiple entries in 'errorformat' *efm-entries* | |
1265 | |
1266 To be able to detect output from several compilers, several format patterns | |
1267 may be put in 'errorformat', separated by commas (note: blanks after the comma | |
1268 are ignored). The first pattern that has a complete match is used. If no | |
1269 match is found, matching parts from the last one will be used, although the | |
1270 file name is removed and the error message is set to the whole message. If | |
1271 there is a pattern that may match output from several compilers (but not in a | |
1272 right way), put it after one that is more restrictive. | |
1273 | |
1274 To include a comma in a pattern precede it with a backslash (you have to type | |
1275 two in a ":set" command). To include a backslash itself give two backslashes | |
1276 (you have to type four in a ":set" command). You also need to put a backslash | |
1277 before a space for ":set". | |
1278 | |
1279 | |
1280 Valid matches *quickfix-valid* | |
1281 | |
1282 If a line does not completely match one of the entries in 'errorformat', the | |
1283 whole line is put in the error message and the entry is marked "not valid" | |
1284 These lines are skipped with the ":cn" and ":cp" commands (unless there is | |
1285 no valid line at all). You can use ":cl!" to display all the error messages. | |
1286 | |
1287 If the error format does not contain a file name Vim cannot switch to the | |
1288 correct file. You will have to do this by hand. | |
1289 | |
1290 | |
1291 Examples | |
1292 | |
1293 The format of the file from the Amiga Aztec compiler is: | |
1294 | |
1295 filename>linenumber:columnnumber:errortype:errornumber:errormessage | |
1296 | |
1297 filename name of the file in which the error was detected | |
1298 linenumber line number where the error was detected | |
1299 columnnumber column number where the error was detected | |
1300 errortype type of the error, normally a single 'E' or 'W' | |
1301 errornumber number of the error (for lookup in the manual) | |
1302 errormessage description of the error | |
1303 | |
1304 This can be matched with this 'errorformat' entry: | |
1305 %f>%l:%c:%t:%n:%m | |
1306 | |
1307 Some examples for C compilers that produce single-line error outputs: | |
1308 %f:%l:\ %t%*[^0123456789]%n:\ %m for Manx/Aztec C error messages | |
1309 (scanf() doesn't understand [0-9]) | |
1310 %f\ %l\ %t%*[^0-9]%n:\ %m for SAS C | |
1311 \"%f\"\\,%*[^0-9]%l:\ %m for generic C compilers | |
1312 %f:%l:\ %m for GCC | |
1313 %f:%l:\ %m,%Dgmake[%*\\d]:\ Entering\ directory\ `%f', | |
1314 %Dgmake[%*\\d]:\ Leaving\ directory\ `%f' | |
1315 for GCC with gmake (concat the lines!) | |
1316 %f(%l)\ :\ %*[^:]:\ %m old SCO C compiler (pre-OS5) | |
1317 %f(%l)\ :\ %t%*[^0-9]%n:\ %m idem, with error type and number | |
1318 %f:%l:\ %m,In\ file\ included\ from\ %f:%l:,\^I\^Ifrom\ %f:%l%m | |
1319 for GCC, with some extras | |
1320 | |
1321 Extended examples for the handling of multi-line messages are given below, | |
1322 see |errorformat-Jikes| and |errorformat-LaTeX|. | |
1323 | |
1324 Note the backslash in front of a space and double quote. It is required for | |
1325 the :set command. There are two backslashes in front of a comma, one for the | |
1326 :set command and one to avoid recognizing the comma as a separator of error | |
1327 formats. | |
1328 | |
1329 | |
1330 Filtering messages | |
1331 | |
1332 If you have a compiler that produces error messages that do not fit in the | |
1333 format string, you could write a program that translates the error messages | |
1334 into this format. You can use this program with the ":make" command by | |
1335 changing the 'makeprg' option. For example: > | |
1336 :set mp=make\ \\\|&\ error_filter | |
1337 The backslashes before the pipe character are required to avoid it to be | |
1338 recognized as a command separator. The backslash before each space is | |
1339 required for the set command. | |
1340 | |
1341 ============================================================================= | |
1342 8. The directory stack *quickfix-directory-stack* | |
1343 | |
1344 Quickfix maintains a stack for saving all used directories parsed from the | |
237 | 1345 make output. For GNU-make this is rather simple, as it always prints the |
1346 absolute path of all directories it enters and leaves. Regardless if this is | |
7 | 1347 done via a 'cd' command in the makefile or with the parameter "-C dir" (change |
237 | 1348 to directory before reading the makefile). It may be useful to use the switch |
7 | 1349 "-w" to force GNU-make to print out the working directory before and after |
1350 processing. | |
1351 | |
1352 Maintaining the correct directory is more complicated if you don't use | |
237 | 1353 GNU-make. AIX-make for example doesn't print any information about its |
1354 working directory. Then you need to enhance the makefile. In the makefile of | |
1355 LessTif there is a command which echoes "Making {target} in {dir}". The | |
2072 | 1356 special problem here is that it doesn't print information on leaving the |
237 | 1357 directory and that it doesn't print the absolute path. |
7 | 1358 |
1359 To solve the problem with relative paths and missing "leave directory" | |
1360 messages Vim uses following algorithm: | |
1361 | |
1362 1) Check if the given directory is a subdirectory of the current directory. | |
1363 If this is true, store it as the current directory. | |
1364 2) If it is not a subdir of the current directory, try if this is a | |
1365 subdirectory of one of the upper directories. | |
1366 3) If the directory still isn't found, it is assumed to be a subdirectory | |
1367 of Vim's current directory. | |
1368 | |
1369 Additionally it is checked for every file, if it really exists in the | |
1370 identified directory. If not, it is searched in all other directories of the | |
237 | 1371 directory stack (NOT the directory subtree!). If it is still not found, it is |
7 | 1372 assumed that it is in Vim's current directory. |
1373 | |
2285
69064995302a
Change SKIP_GTK to SKIP_GTK2 in configure.
Bram Moolenaar <bram@vim.org>
parents:
2283
diff
changeset
|
1374 There are limitations in this algorithm. These examples assume that make just |
7 | 1375 prints information about entering a directory in the form "Making all in dir". |
1376 | |
1377 1) Assume you have following directories and files: | |
1378 ./dir1 | |
1379 ./dir1/file1.c | |
1380 ./file1.c | |
1381 | |
1382 If make processes the directory "./dir1" before the current directory and | |
1383 there is an error in the file "./file1.c", you will end up with the file | |
1384 "./dir1/file.c" loaded by Vim. | |
1385 | |
1386 This can only be solved with a "leave directory" message. | |
1387 | |
1388 2) Assume you have following directories and files: | |
1389 ./dir1 | |
1390 ./dir1/dir2 | |
1391 ./dir2 | |
1392 | |
1393 You get the following: | |
1394 | |
1395 Make output Directory interpreted by Vim | |
1396 ------------------------ ---------------------------- | |
1397 Making all in dir1 ./dir1 | |
1398 Making all in dir2 ./dir1/dir2 | |
1399 Making all in dir2 ./dir1/dir2 | |
1400 | |
1401 This can be solved by printing absolute directories in the "enter directory" | |
1402 message or by printing "leave directory" messages.. | |
1403 | |
2207
b17bbfa96fa0
Add the settabvar() and gettabvar() functions.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
1404 To avoid this problem, ensure to print absolute directory names and "leave |
7 | 1405 directory" messages. |
1406 | |
1407 Examples for Makefiles: | |
1408 | |
1409 Unix: | |
1410 libs: | |
1411 for dn in $(LIBDIRS); do \ | |
1412 (cd $$dn; echo "Entering dir '$$(pwd)'"; make); \ | |
1413 echo "Leaving dir"; \ | |
1414 done | |
1415 | |
1416 Add | |
1417 %DEntering\ dir\ '%f',%XLeaving\ dir | |
1418 to your 'errorformat' to handle the above output. | |
1419 | |
1420 Note that Vim doesn't check if the directory name in a "leave directory" | |
237 | 1421 messages is the current directory. This is why you could just use the message |
7 | 1422 "Leaving dir". |
1423 | |
1424 ============================================================================= | |
1425 9. Specific error file formats *errorformats* | |
1426 | |
1427 *errorformat-Jikes* | |
1428 Jikes(TM), a source-to-bytecode Java compiler published by IBM Research, | |
1429 produces simple multi-line error messages. | |
1430 | |
1431 An 'errorformat' string matching the produced messages is shown below. | |
1432 The following lines can be placed in the user's |vimrc| to overwrite Vim's | |
1433 recognized default formats, or see |:set+=| how to install this format | |
1434 additionally to the default. > | |
1435 | |
1436 :set efm=%A%f:%l:%c:%*\\d:%*\\d:, | |
1437 \%C%*\\s%trror:%m, | |
1438 \%+C%*[^:]%trror:%m, | |
1439 \%C%*\\s%tarning:%m, | |
1440 \%C%m | |
1441 < | |
1442 Jikes(TM) produces a single-line error message when invoked with the option | |
1443 "+E", and can be matched with the following: > | |
1444 | |
1167 | 1445 :setl efm=%f:%l:%v:%*\\d:%*\\d:%*\\s%m |
7 | 1446 < |
1447 *errorformat-javac* | |
1448 This 'errorformat' has been reported to work well for javac, which outputs a | |
1449 line with "^" to indicate the column of the error: > | |
1167 | 1450 :setl efm=%A%f:%l:\ %m,%-Z%p^,%-C%.%# |
7 | 1451 or: > |
1167 | 1452 :setl efm=%A%f:%l:\ %m,%+Z%p^,%+C%.%#,%-G%.%# |
7 | 1453 < |
1167 | 1454 Here is an alternative from Michael F. Lamb for Unix that filters the errors |
1455 first: > | |
1456 :setl errorformat=%Z%f:%l:\ %m,%A%p^,%-G%*[^sl]%.%# | |
5690 | 1457 :setl makeprg=javac\ %:S\ 2>&1\ \\\|\ vim-javac-filter |
1167 | 1458 |
1459 You need to put the following in "vim-javac-filter" somewhere in your path | |
1460 (e.g., in ~/bin) and make it executable: > | |
1461 #!/bin/sed -f | |
1462 /\^$/s/\t/\ /g;/:[0-9]\+:/{h;d};/^[ \t]*\^/G; | |
1463 | |
1464 In English, that sed script: | |
1465 - Changes single tabs to single spaces and | |
1466 - Moves the line with the filename, line number, error message to just after | |
1467 the pointer line. That way, the unused error text between doesn't break | |
1468 vim's notion of a "multi-line message" and also doesn't force us to include | |
1469 it as a "continuation of a multi-line message." | |
1470 | |
7 | 1471 *errorformat-ant* |
1472 For ant (http://jakarta.apache.org/) the above errorformat has to be modified | |
1473 to honour the leading [javac] in front of each javac output line: > | |
1474 :set efm=%A\ %#[javac]\ %f:%l:\ %m,%-Z\ %#[javac]\ %p^,%-C%.%# | |
1475 | |
1476 The 'errorformat' can also be configured to handle ant together with either | |
1477 javac or jikes. If you're using jikes, you should tell ant to use jikes' +E | |
1478 command line switch which forces jikes to generate one-line error messages. | |
1479 This is what the second line (of a build.xml file) below does: > | |
1480 <property name = "build.compiler" value = "jikes"/> | |
1481 <property name = "build.compiler.emacs" value = "true"/> | |
1482 | |
1483 The 'errorformat' which handles ant with both javac and jikes is: > | |
1484 :set efm=\ %#[javac]\ %#%f:%l:%c:%*\\d:%*\\d:\ %t%[%^:]%#:%m, | |
1485 \%A\ %#[javac]\ %f:%l:\ %m,%-Z\ %#[javac]\ %p^,%-C%.%# | |
1486 < | |
1487 *errorformat-jade* | |
1488 parsing jade (see http://www.jclark.com/) errors is simple: > | |
1489 :set efm=jade:%f:%l:%c:%t:%m | |
1490 < | |
1491 *errorformat-LaTeX* | |
1492 The following is an example how an 'errorformat' string can be specified | |
1493 for the (La)TeX typesetting system which displays error messages over | |
1494 multiple lines. The output of ":clist" and ":cc" etc. commands displays | |
1495 multi-lines in a single line, leading white space is removed. | |
1496 It should be easy to adopt the above LaTeX errorformat to any compiler output | |
1497 consisting of multi-line errors. | |
1498 | |
1499 The commands can be placed in a |vimrc| file or some other Vim script file, | |
237 | 1500 e.g. a script containing LaTeX related stuff which is loaded only when editing |
7 | 1501 LaTeX sources. |
1502 Make sure to copy all lines of the example (in the given order), afterwards | |
1503 remove the comment lines. For the '\' notation at the start of some lines see | |
1504 |line-continuation|. | |
1505 | |
1506 First prepare 'makeprg' such that LaTeX will report multiple | |
1507 errors; do not stop when the first error has occurred: > | |
1508 :set makeprg=latex\ \\\\nonstopmode\ \\\\input\\{$*} | |
1509 < | |
1510 Start of multi-line error messages: > | |
1511 :set efm=%E!\ LaTeX\ %trror:\ %m, | |
1512 \%E!\ %m, | |
1513 < Start of multi-line warning messages; the first two also | |
237 | 1514 include the line number. Meaning of some regular expressions: |
7 | 1515 - "%.%#" (".*") matches a (possibly empty) string |
1516 - "%*\\d" ("\d\+") matches a number > | |
1517 \%+WLaTeX\ %.%#Warning:\ %.%#line\ %l%.%#, | |
1518 \%+W%.%#\ at\ lines\ %l--%*\\d, | |
1519 \%WLaTeX\ %.%#Warning:\ %m, | |
1520 < Possible continuations of error/warning messages; the first | |
1521 one also includes the line number: > | |
1522 \%Cl.%l\ %m, | |
1523 \%+C\ \ %m., | |
1524 \%+C%.%#-%.%#, | |
1525 \%+C%.%#[]%.%#, | |
1526 \%+C[]%.%#, | |
1527 \%+C%.%#%[{}\\]%.%#, | |
1528 \%+C<%.%#>%.%#, | |
1529 \%C\ \ %m, | |
1530 < Lines that match the following patterns do not contain any | |
1531 important information; do not include them in messages: > | |
1532 \%-GSee\ the\ LaTeX%m, | |
1533 \%-GType\ \ H\ <return>%m, | |
1534 \%-G\ ...%.%#, | |
1535 \%-G%.%#\ (C)\ %.%#, | |
1536 \%-G(see\ the\ transcript%.%#), | |
1537 < Generally exclude any empty or whitespace-only line from | |
1538 being displayed: > | |
1539 \%-G\\s%#, | |
1540 < The LaTeX output log does not specify the names of erroneous | |
1541 source files per line; rather they are given globally, | |
1542 enclosed in parentheses. | |
1543 The following patterns try to match these names and store | |
1544 them in an internal stack. The patterns possibly scan over | |
1545 the same input line (one after another), the trailing "%r" | |
1546 conversion indicates the "rest" of the line that will be | |
1547 parsed in the next go until the end of line is reached. | |
1548 | |
1549 Overread a file name enclosed in '('...')'; do not push it | |
1550 on a stack since the file apparently does not contain any | |
1551 error: > | |
1552 \%+O(%f)%r, | |
237 | 1553 < Push a file name onto the stack. The name is given after '(': > |
7 | 1554 \%+P(%f%r, |
1555 \%+P\ %\\=(%f%r, | |
1556 \%+P%*[^()](%f%r, | |
1557 \%+P[%\\d%[^()]%#(%f%r, | |
1558 < Pop the last stored file name when a ')' is scanned: > | |
1559 \%+Q)%r, | |
1560 \%+Q%*[^()])%r, | |
1561 \%+Q[%\\d%*[^()])%r | |
1562 | |
1563 Note that in some cases file names in the LaTeX output log cannot be parsed | |
1564 properly. The parser might have been messed up by unbalanced parentheses | |
1565 then. The above example tries to catch the most relevant cases only. | |
1566 You can customize the given setting to suit your own purposes, for example, | |
1567 all the annoying "Overfull ..." warnings could be excluded from being | |
1568 recognized as an error. | |
1569 Alternatively to filtering the LaTeX compiler output, it is also possible | |
1570 to directly read the *.log file that is produced by the [La]TeX compiler. | |
1571 This contains even more useful information about possible error causes. | |
1572 However, to properly parse such a complex file, an external filter should | |
1573 be used. See the description further above how to make such a filter known | |
1574 by Vim. | |
1575 | |
1576 *errorformat-Perl* | |
1577 In $VIMRUNTIME/tools you can find the efm_perl.pl script, which filters Perl | |
1578 error messages into a format that quickfix mode will understand. See the | |
1624 | 1579 start of the file about how to use it. (This script is deprecated, see |
1580 |compiler-perl|.) | |
7 | 1581 |
1582 | |
1583 | |
1584 vim:tw=78:ts=8:ft=help:norl: |