Mercurial > vim
comparison runtime/doc/quickfix.txt @ 41:f529edb9bab3 v7.0025
updated for version 7.0025
author | vimboss |
---|---|
date | Mon, 27 Dec 2004 21:59:20 +0000 |
parents | 4102fb4ea781 |
children | f55897d6921d |
comparison
equal
deleted
inserted
replaced
40:f1d2a58883b9 | 41:f529edb9bab3 |
---|---|
1 *quickfix.txt* For Vim version 7.0aa. Last change: 2004 Jun 16 | 1 *quickfix.txt* For Vim version 7.0aa. Last change: 2004 Dec 27 |
2 | 2 |
3 | 3 |
4 VIM REFERENCE MANUAL by Bram Moolenaar | 4 VIM REFERENCE MANUAL by Bram Moolenaar |
5 | 5 |
6 | 6 |
102 | 102 |
103 *:cg* *:cgetfile* | 103 *:cg* *:cgetfile* |
104 :cg[etfile][!] [errorfile] | 104 :cg[etfile][!] [errorfile] |
105 Read the error file. Just like ":cfile" but don't | 105 Read the error file. Just like ":cfile" but don't |
106 jump to the first error. | 106 jump to the first error. |
107 | |
108 *:cb* *:cbuffer* *E681* | |
109 :cb[uffer] [bufnr] Read the error list from the current buffer. | |
110 When [bufnr] is given it must be the number of a | |
111 loaded buffer. That buffer will then be used instead | |
112 of the current buffer. | |
113 A range can be specified for the lines to be used. | |
114 Otherwise all lines in the buffer are used. | |
107 | 115 |
108 *:cl* *:clist* | 116 *:cl* *:clist* |
109 :cl[ist] [from] [, [to]] | 117 :cl[ist] [from] [, [to]] |
110 List all errors that are valid |quickfix-valid|. | 118 List all errors that are valid |quickfix-valid|. |
111 If numbers [from] and/or [to] are given, the respective | 119 If numbers [from] and/or [to] are given, the respective |
264 | 272 |
265 If 'shellpipe' is empty, the {errorfile} part will be omitted. This is useful | 273 If 'shellpipe' is empty, the {errorfile} part will be omitted. This is useful |
266 for compilers that write to an errorfile themselves (e.g., Manx's Amiga C). | 274 for compilers that write to an errorfile themselves (e.g., Manx's Amiga C). |
267 | 275 |
268 ============================================================================== | 276 ============================================================================== |
269 5. Using :grep *grep* *lid* | 277 5. Using :vimgrep and :grep *grep* *lid* |
278 | |
279 Vim has two ways to find matches for a pattern: Internal and external. The | |
280 advantage of the internal grep is that it works on all systems and uses the | |
281 powerful Vim search patterns. An external grep program can be used when the | |
282 Vim grep does not do what you want. | |
283 | |
284 The internal method may be a bit slower, because files are read into memory. | |
285 The advantage is that line separators and encoding are automatically | |
286 recognized, as if a file is being edited. And multi-line patterns can be | |
287 used. | |
288 | |
289 | |
290 5.1 using Vim's internal grep | |
291 | |
292 *:vim* *:vimgrep* | |
293 :vim[grep][!] /{pattern}/ {file} ... | |
294 Search for {pattern} in the files {file} ... and set | |
295 the error list to the matches. | |
296 {pattern} if a Vim search pattern. Instead of | |
297 enclosing it in / any character can be used, so long | |
298 as it does not appear in {pattern}. | |
299 | |
300 *:vimgrepa* *:vimgrepadd* | |
301 :vimgrepa[dd][!] /{pattern}/ {file} ... | |
302 Just like ":vimgrep", but instead of making a new list | |
303 of errors the matches are appended to the current | |
304 list. | |
305 | |
306 | |
307 5.2 External grep | |
270 | 308 |
271 Vim can interface with "grep" and grep-like programs (such as the GNU | 309 Vim can interface with "grep" and grep-like programs (such as the GNU |
272 id-utils) in a similar way to its compiler integration (see |:make| above). | 310 id-utils) in a similar way to its compiler integration (see |:make| above). |
273 | 311 |
274 [Unix trivia: The name for the Unix "grep" command comes from ":g/re/p", where | 312 [Unix trivia: The name for the Unix "grep" command comes from ":g/re/p", where |
275 "re" stands for Regular Expression.] | 313 "re" stands for Regular Expression.] |
276 | 314 |
277 *:gr* *:grep* | 315 *:gr* *:grep* |
278 :gr[ep][!] [arguments] Just like ":make", but use 'grepprg' instead of | 316 :gr[ep][!] [arguments] Just like ":make", but use 'grepprg' instead of |
279 'makeprg' and 'grepformat' instead of 'errorformat'. | 317 'makeprg' and 'grepformat' instead of 'errorformat'. |
318 When 'grepprg' is "internal" this works like | |
319 |:vimgrep|. Note that the pattern needs to be | |
320 enclosed in separator characters then. | |
280 *:grepa* *:grepadd* | 321 *:grepa* *:grepadd* |
281 :grepa[dd][!] [arguments] | 322 :grepa[dd][!] [arguments] |
282 Just like ":grep", but instead of making a new list of | 323 Just like ":grep", but instead of making a new list of |
283 errors the matches are appended to the current list. | 324 errors the matches are appended to the current list. |
284 Example: > | 325 Example: > |
288 empty. The second command executes "grepadd" for each | 329 empty. The second command executes "grepadd" for each |
289 listed buffer. Note the use of ! to avoid that | 330 listed buffer. Note the use of ! to avoid that |
290 ":grepadd" jumps to the first error, which is not | 331 ":grepadd" jumps to the first error, which is not |
291 allowed with |:bufdo|. | 332 allowed with |:bufdo|. |
292 | 333 |
293 5.1 Setting up grep | 334 5.3 Setting up external grep |
294 | 335 |
295 If you have a standard "grep" program installed, the :grep command may work | 336 If you have a standard "grep" program installed, the :grep command may work |
296 well with the defaults. The syntax is very similar to the standard command: > | 337 well with the defaults. The syntax is very similar to the standard command: > |
297 | 338 |
298 :grep foo *.c | 339 :grep foo *.c |
320 jumps to the appropriate line, in the same way that it jumps to a compiler | 361 jumps to the appropriate line, in the same way that it jumps to a compiler |
321 error in |quickfix| mode. You can then use the |:cnext|, |:clist|, etc. | 362 error in |quickfix| mode. You can then use the |:cnext|, |:clist|, etc. |
322 commands to see the other matches. | 363 commands to see the other matches. |
323 | 364 |
324 | 365 |
325 5.2 Using :grep with id-utils | 366 5.4 Using :grep with id-utils |
326 | 367 |
327 You can set up :grep to work with the GNU id-utils like this: > | 368 You can set up :grep to work with the GNU id-utils like this: > |
328 | 369 |
329 :set grepprg=lid\ -Rgrep\ -s | 370 :set grepprg=lid\ -Rgrep\ -s |
330 :set grepformat=%f:%l:%m | 371 :set grepformat=%f:%l:%m |
334 | 375 |
335 works just as you'd expect. | 376 works just as you'd expect. |
336 (provided you remembered to mkid first :) | 377 (provided you remembered to mkid first :) |
337 | 378 |
338 | 379 |
339 5.3 Browsing source code with :grep | 380 5.5 Browsing source code with :vimgrep or :grep |
340 | 381 |
341 Using the stack of error lists that Vim keeps, you can browse your files to | 382 Using the stack of error lists that Vim keeps, you can browse your files to |
342 look for functions and the functions they call. For example, suppose that you | 383 look for functions and the functions they call. For example, suppose that you |
343 have to add an argument to the read_file() function. You enter this command: > | 384 have to add an argument to the read_file() function. You enter this command: > |
344 | 385 |
345 :grep read_file *.c | 386 :vimgrep /\<read_file\>/ *.c |
346 | 387 |
347 You use ":cn" to go along the list of matches and add the argument. At one | 388 You use ":cn" to go along the list of matches and add the argument. At one |
348 place you have to get the new argument from a higher level function msg(), and | 389 place you have to get the new argument from a higher level function msg(), and |
349 need to change that one too. Thus you use: > | 390 need to change that one too. Thus you use: > |
350 | 391 |
351 :grep msg *.c | 392 :vimgrep /\<msg\>/ *.c |
352 | 393 |
353 While changing the msg() functions, you find another function that needs to | 394 While changing the msg() functions, you find another function that needs to |
354 get the argument from a higher level. You can again use ":grep" to find these | 395 get the argument from a higher level. You can again use ":vimgrep" to find |
355 functions. Once you are finished with one function, you can use > | 396 these functions. Once you are finished with one function, you can use > |
356 | 397 |
357 :colder | 398 :colder |
358 | 399 |
359 to go back to the previous one. | 400 to go back to the previous one. |
360 | 401 |
361 This works like browsing a tree: ":grep" goes one level deeper, creating a | 402 This works like browsing a tree: ":vimgrep" goes one level deeper, creating a |
362 list of branches. ":colder" goes back to the previous level. You can mix | 403 list of branches. ":colder" goes back to the previous level. You can mix |
363 this use of ":grep" and "colder" to browse all the locations in a tree-like | 404 this use of ":vimgrep" and "colder" to browse all the locations in a tree-like |
364 way. If you do this consistently, you will find all locations without the | 405 way. If you do this consistently, you will find all locations without the |
365 need to write down a "todo" list. | 406 need to write down a "todo" list. |
366 | 407 |
367 ============================================================================= | 408 ============================================================================= |
368 6. Selecting a compiler *compiler-select* | 409 6. Selecting a compiler *compiler-select* |