📄 quickfix.txt
字号:
*quickfix.txt* For Vim version 5.8. Last change: 1999 Oct 28 VIM REFERENCE MANUAL by Bram Moolenaar{Vi does not have any of these commands}The quickfix commands are not available when the |+quickfix| feature wasdisabled at compile time.Using the QuickFix mode *quickfix* *Quickfix*Vim has a special mode to speedup the edit-compile-edit cycle. This isinspired by the quickfix option of the Manx's Aztec C compiler on the Amiga.The idea is to save the error messages from the compiler in a file and useVim to jump to the errors one by one. You can then examine each problem andfix it, without having to remember all the error messages.If you are using Manx's Aztec C compiler on the Amiga you should do thefollowing:- Set the CCEDIT environment variable with the command mset "CCEDIT=vim -q"- Compile with the -qf option. If the compiler finds any errors, Vim is started and the cursor is positioned on the first error. The error message will be displayed on the last line. You can go to other errors with the commands mentioned below. You can fix the errors and write the file(s).- If you exit Vim normally the compiler will re-compile the same file. If you exit with the :cq command, the compiler will terminate. Do this if you cannot fix the error, or if another file needs to be compiled first.If you are using another compiler you should save the error messages in afile and start Vim with "vim -q filename". An easy way to do this is withthe ":make" command (see below). The 'errorformat' option should be set tomatch the error messages from your compiler (see below).The following commands can be used if you are in QuickFix mode: *:cc*:cc[!] [nr] Display error [nr]. If [nr] is omitted, the same error is displayed again. Without [!] this doesn't work when jumping to another buffer, the current buffer has been changed, there is the only window for the buffer and both 'hidden' and 'autowrite' are off. When jumping to another buffer with [!] any changes to the current buffer are lost, unless 'hidden' is set or there is another window for this buffer. The 'switchbuf' settings are respected when jumping to a buffer. *:cn* *:cnext*:[count]cn[ext][!] Display the [count] next error in the list that includes a file name. If there are no file names at all, go to the [count] next error. See |:cc| for [!] and 'switchbuf'.:[count]cN[ext][!] *:cp* *:cprevious* *:cN* *:cNext*:[count]cp[revious][!] Display the [count] previous error in the list that includes a file name. If there are no file names at all, go to the [count] previous error. See |:cc| for [!] and 'switchbuf'. *:cnf* *:cnfile*:[count]cnf[ile][!] Display the first error in the [count] next file in the list that includes a file name. If there are no file names at all or if there is no next file, go to the [count] next error. See |:cc| for [!] and 'switchbuf'. *:crewind* *:cr*:cr[ewind][!] [nr] Display error [nr]. If [nr] is omitted, the FIRST error is displayed. See |:cc|. *:clast* *:cla*:cla[st][!] [nr] Display error [nr]. If [nr] is omitted, the LAST error is displayed. See |:cc|. *:cq* *:cquit*:cq[uit] Quit Vim with an error code, so that the compiler will not compile the same file again. *:cf* *:cfile*:cf[ile][!] [errorfile] Read the error file and jump to the first error. This is done automatically when Vim is started with the -q option. You can use this command when you keep Vim running while compiling. If you give the name of the errorfile, the 'errorfile' option will be set to [errorfile]. See |:cc| for [!]. *:cl* *:clist*:cl[ist] [from] [, [to]] List all errors that include a file name. If numbers [from] and/or [to] are given, the respective range of errors is listed. A negative number counts from the last error backwards, -1 being the last error. The 'switchbuf' settings are respected when jumping to a buffer.:cl[ist]! [from] [, [to]] List all errors. *:mak* *:make*:mak[e] [arguments] 1. If the 'autowrite' option is on, write any changed buffers 2. An errorfile name is made from 'makeef'. If 'makeef' doesn't contain "##", and a file with this name already exists, it is deleted. 3. The program given with the 'makeprg' option is started (default "make") with the optional [arguments] and the output is saved in the errorfile (for Unix it is also echoed on the screen). 4. The errorfile is then read and the first error is jumped to. 5. The errorfile is deleted. This command does not accept a comment, any " characters are considered part of the arguments. *:gr* *:grep*:gr[ep] [arguments] Just like ":make", but use 'grepprg' instead of 'makeprg' and 'grepformat' instead of 'errorformat'. See |grep|. [Unix trivia: The name for the Unix "grep" command comes from ":g/re/p", where "re" stands for Regular Expression.]A template for the errorfile name can be set with the 'makeef' option. If itincludes "##", Vim will replace this with a number to make it a unique name.The format of the file from the Aztec compiler is: filename>linenumber:columnnumber:errortype:errornumber:errormessage filename name of the file in which the error was detected linenumber line number where the error was detected columnnumber column number where the error was detected errortype type of the error, normally a single 'E' or 'W' errornumber number of the error (for lookup in the manual) errormessage description of the error *errorformat*Another compiler is likely to use a different format. You should set the'errorformat' option to a scanf-like string that describes the format.First, you need to know how scanf works. Look in the documentation of yourC compiler. Vim will understand the following conversion characters.Others are invalid. %f file name (finds a string) %l line number (finds a number) %c column number (finds a number) %t error type (finds a single character) %n error number (finds a number) %m error message (finds a string) %r matches the "rest" of a single-line file message %O/P/Q %*{conv} any scanf non-assignable conversion %% the single '%' characterThe following uppercase conversion characters specify the type of specialformat strings. At most one of them may be given as a prefix at the beginof a single comma-separated format pattern.Some compilers produce messages that consist of directory names that have tobe prepended to each file name read by %f (example: GUN make). The followingcodes can be used to scan these directory names; they will be stored in aninternal directory stack. %D "enter directory" format string; expects a following %f that finds the directory name %X "leave directory" format string; expects following %f *errorformat-multi-line*It is possible to read the output of programs that produce multi-line messages,ie. error strings that consume more than one line. Possible prefixes are: %A start of a multi-line message (unspecified type) %E start of a multi-line error message %W start of a multi-line warning message %C continuation of a multi-line message %Z end of a multi-line message %G global; useful only in conjunction with '+' or '-' %O single-line file message: overread the matched part %P single-line file message: push file %f onto the stack %Q single-line file message: pop the last file from stackThe codes '+' or '-' can be combined with the uppercase codes above; in thatcase they have to precede the letter, eg. '%+A' or '%-G': %- do not include the matching line in any output %+ include the whole matching line in the %m error stringThe scanf()-like "%*[]" notation is supported for backward-compatibilitywith previous versions of Vim. However, it is also possible to specify(nearly) any Vim supported regular expression in format strings.Since meta characters of the regular expression language can be part ofordinary matching strings or file names (and therefore internally have tobe escaped), meta symbols have to be written with leading '%': %\ the single '\' character. Note that this has to be escaped ("%\\") in ":set errorformat=" definitions. %. the single '.' character. %# the single '*'(!) character. %^ the single '^' character. %$ the single '$' character. %[ the single '[' character. %~ the single '~' character.When using character classes in expressions (see |/\i| for an overview),terms containing the "\+" quantifier can be written in the scanf() "%*"notation. Example: "%\\d%\\+" ("\d\+", "any number") is equivalent to "%*\\d".Important note: The \(...\) grouping of expressions can not be used in formatspecifications because it is reserved for internal conversions.Some examples for C compilers that produce single-line error outputs:%f>%l:%c:%t:%n:%m" for the AztecC.Err file%f:%l:\ %t%*[^0123456789]%n:\ %m for Manx/Aztec C error messages (scanf() doesn't understand [0-9])%f\ %l\ %t%*[^0-9]%n:\ %m for SAS C\"%f\"\\,%*[^0-9]%l:\ %m for generic C compilers%f:%l:\ %m for GCC%f:%l:\ %m,%Dgmake[%*\\d]:\ Entering\ directory\ `%f',%Dgmake[%*\\d]:\ Leaving\ directory\ `%f' for GCC with gmake (concat the lines!)%f(%l)\ :\ %*[^:]:\ %m old SCO C compiler (pre-OS5)%f(%l)\ :\ %t%*[^0-9]%n:\ %m idem, with error type and number%f:%l:\ %m,In\ file\ included\ from\ %f:%l:,\^I\^Ifrom\ %f:%l%m for GCC, with some extrasExtended examples for the handling of multi-line messages are given below,see |errorformat-Jikes| and |errorformat-LaTeX|.Note the backslash in front of a space and double quote. It is required forthe :set command. There are two backslashes in front of a comma, one for the:set command and one to avoid recognizing the comma as a separator of errorformats.The "%f" conversion depends on the current 'isfname' setting.The "%f" and "%m" conversions have to detect the end of the string. Theyshould be followed by a character that cannot be in the string. Everythingup to that character is included in the string. Be careful: "%f%l" willinclude everything up to the first '%' in the file name. If the "%f" or "%m"is at the end, everything up to the end of the line is included.When defining an "enter directory" or "leave directory" format, the "%D" or"%X" has to be given at the start of that substring. Vim tracks the directorychanges and prepends the current directory to each erroneous file found with arelative path. See |quickfix-directory-stack| for details, tips andlimitations.To be able to detect output from several compilers, several format patternsmay be put in 'errorformat', separated by commas (note: blanks after the commaare ignored). The first pattern that has a complete match is used. If nomatch is found, matching parts from the last one will be used, although thefile name is removed and the error message is set to the whole message. Ifthere is a pattern that may match output from several compilers (but not in aright way), put it after one that is more restrictive. To include a comma ina pattern precede it with a backslash (you have to type two in a set command).To include a backslash itself give two backslashes (you have to type four in aset command).If a line is detected that does not completely match the 'errorformat', thewhole line is put in the error message and the entry is marked "not valid"These lines are skipped with the ":cn" and ":cp" commands (unless there isno valid line at all). You can use ":cl!" to display all the error messages.If the error format does not contain a file name Vim cannot switch to thecorrect file. You will have to do this by hand.If you have a compiler that produces error messages that do not fit in theformat string, you could write a program that translates the error messagesinto this format. You can use this program with the ":make" command bychanging the 'makeprg' option. For example:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -