Nvim :help
pages, generated
from source
using the tree-sitter-vimdoc parser.
vim -q filenameFrom inside Vim an easy way to run a command and handle the output is with the :make command (see below).
quickfix-ID
Each quickfix list has a unique identifier called the quickfix ID and this
number will not change within a Vim session. The getqflist() function can be
used to get the identifier assigned to a list. There is also a quickfix list
number which may change whenever more than ten lists are added to a quickfix
stack.location-list
E776
A location list is a window-local quickfix list. You get one after commands
like :lvimgrep
, :lgrep
, :lhelpgrep
, :lmake
, etc., which create a
location list instead of a quickfix list as the corresponding :vimgrep
,
:grep
, :helpgrep
, :make
do.
location-list-file-window
A location list is associated with a window and each window can have a
separate location list. A location list can be associated with only one
window. The location list is independent of the quickfix list.quickfix-changedtick
Every quickfix and location list has a read-only changedtick variable that
tracks the total number of changes made to the list. Every time the quickfix
list is modified, this count is incremented. This can be used to perform an
action only when the list has changed. The getqflist() and getloclist()
functions can be used to query the current value of changedtick. You cannot
change the changedtick variable.E924
If the current window was closed by an autocommand while processing a
location list command, it will be aborted.E925
E926
If the current quickfix or location list was changed by an autocommand while
processing a quickfix or location list command, it will be aborted.:cc
:cc[!] [nr] Display error [nr]. If [nr] is omitted, the same
:[nr]cc[!] 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.
When used in the quickfix window the line number can
be used, including "." for the current line and "$"
for the last line.:ll
:ll[!] [nr] Same as ":cc", except the location list for the
:[nr]ll[!] current window is used instead of the quickfix list.:cn
:cne
:cnext
E553
:[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'.:lne
:lnext
:[count]lne[xt][!] Same as ":cnext", except the location list for the
current window is used instead of the quickfix list.:cp
:cprevious
:cprev
: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'.:lp
:lprevious
:lprev
:lN
:lNext
:[count]lp[revious][!] Same as ":cNext" and ":cprevious", except the location
list for the current window is used instead of the
quickfix list.:cabo
:cabove
:[count]cabo[ve] Go to the [count] error above the current line in the
current buffer. If [count] is omitted, then 1 is
used. If there are no errors, then an error message
is displayed. Assumes that the entries in a quickfix
list are sorted by their buffer number and line
number. If there are multiple errors on the same line,
then only the first entry is used. If [count] exceeds
the number of entries above the current line, then the
first error in the file is selected.:lab
:labove
:[count]lab[ove] Same as ":cabove", except the location list for the
current window is used instead of the quickfix list.:cbel
:cbelow
:[count]cbel[ow] Go to the [count] error below the current line in the
current buffer. If [count] is omitted, then 1 is
used. If there are no errors, then an error message
is displayed. Assumes that the entries in a quickfix
list are sorted by their buffer number and line
number. If there are multiple errors on the same
line, then only the first entry is used. If [count]
exceeds the number of entries below the current line,
then the last error in the file is selected.:lbel
:lbelow
:[count]lbel[ow] Same as ":cbelow", except the location list for the
current window is used instead of the quickfix list.:cbe
:cbefore
:[count]cbe[fore] Go to the [count] error before the current cursor
position in the current buffer. If [count] is
omitted, then 1 is used. If there are no errors, then
an error message is displayed. Assumes that the
entries in a quickfix list are sorted by their buffer,
line and column numbers. If [count] exceeds the
number of entries before the current position, then
the first error in the file is selected.:lbe
:lbefore
:[count]lbe[fore] Same as ":cbefore", except the location list for the
current window is used instead of the quickfix list.:caf
:cafter
:[count]caf[ter] Go to the [count] error after the current cursor
position in the current buffer. If [count] is
omitted, then 1 is used. If there are no errors, then
an error message is displayed. Assumes that the
entries in a quickfix list are sorted by their buffer,
line and column numbers. If [count] exceeds the
number of entries after the current position, then
the last error in the file is selected.:laf
:lafter
:[count]laf[ter] Same as ":cafter", except the location list for the
current window is used instead of the quickfix list.: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'.:lnf
:lnfile
:[count]lnf[ile][!] Same as ":cnfile", except the location list for the
current window is used instead of the quickfix list.:cpf
:cpfile
:cNf
:cNfile
:[count]cpf[ile][!] Display the last error in the [count] previous 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] previous error. See :cc for [!] and
'switchbuf'.:lpf
:lpfile
:lNf
:lNfile
:[count]lpf[ile][!] Same as ":cNfile" and ":cpfile", except the location
list for the current window is used instead of the
quickfix list.:crewind
:cr
:cr[ewind][!] [nr] Display error [nr]. If [nr] is omitted, the FIRST
error is displayed. See :cc.:lrewind
:lr
:lr[ewind][!] [nr] Same as ":crewind", except the location list for the
current window is used instead of the quickfix list.:clast
:cla
:cla[st][!] [nr] Display error [nr]. If [nr] is omitted, the LAST
error is displayed. See :cc.:llast
:lla
:lla[st][!] [nr] Same as ":clast", except the location list for the
current window is used instead of the quickfix list.:cq
:cquit
:cq[uit][!]
:{N}cq[uit][!]
:cq[uit][!] {N}
Quit Vim with error code {N}
. {N}
defaults to one.
Useful when Vim is called from another program:
e.g., a compiler will not compile the same file again,
git commit
will abort the committing process, fc
(built-in for shells like bash and zsh) will not
execute the command, etc.
{N}
can also be zero, in which case Vim exits
normally.
WARNING: All changes in files are lost. It works like
":qall!" :qall, except that Nvim exits non-zero or
[count].:cf
:cfi
: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 [!].
If the encoding of the error file differs from the
'encoding' option, you can use the 'makeencoding'
option to specify the encoding.:lf
:lfi
:lfile
:lf[ile][!] [errorfile] Same as ":cfile", except the location list for the
current window is used instead of the quickfix list.
You can not use the -q command-line option to set
the location list.:cg
:cgetfile
Read the error file. Just like ":cfile" but don't
jump to the first error.
If the encoding of the error file differs from the
'encoding' option, you can use the 'makeencoding'
option to specify the encoding.:lg
:lge
:lgetfile
Same as ":cgetfile", except the location list for the
current window is used instead of the quickfix list.:caddf
:caddfile
:caddf[ile] [errorfile] Read the error file and add the errors from the
errorfile to the current quickfix list. If a quickfix
list is not present, then a new list is created.
If the encoding of the error file differs from the
'encoding' option, you can use the 'makeencoding'
option to specify the encoding.:laddf
:laddfile
:laddf[ile] [errorfile] Same as ":caddfile", except the location list for the
current window is used instead of the quickfix list.:cb
:cbuffer
E681
:[range]cb[uffer][!] [bufnr]
Read the error list from the current buffer.
When [bufnr] is given it must be the number of a
loaded buffer. That buffer will then be used instead
of the current buffer.
A range can be specified for the lines to be used.
Otherwise all lines in the buffer are used.
See :cc for [!].:lb
:lbuffer
:[range]lb[uffer][!] [bufnr]
Same as ":cbuffer", except the location list for the
current window is used instead of the quickfix list.:cgetb
:cgetbuffer
:[range]cgetb[uffer] [bufnr]
Read the error list from the current buffer. Just
like ":cbuffer" but don't jump to the first error.:lgetb
:lgetbuffer
:[range]lgetb[uffer] [bufnr]
Same as ":cgetbuffer", except the location list for
the current window is used instead of the quickfix
list.:cad
:cadd
:caddbuffer
:[range]cad[dbuffer] [bufnr]
Read the error list from the current buffer and add
the errors to the current quickfix list. If a
quickfix list is not present, then a new list is
created. Otherwise, same as ":cbuffer".:laddb
:laddbuffer
:[range]laddb[uffer] [bufnr]
Same as ":caddbuffer", except the location list for
the current window is used instead of the quickfix
list.:cex
:cexpr
E777
:cex[pr][!] {expr}
Create a quickfix list using the result of {expr}
and
jump to the first error.
If {expr}
is a String, then each newline terminated
line in the String is processed using the global value
of 'errorformat' and the result is added to the
quickfix list.
If {expr}
is a List, then each String item in the list
is processed and added to the quickfix list. Non
String items in the List are ignored.
See :cc for [!].
Examples::cexpr system('grep -n xyz *') :cexpr getline(1, '$')
:lex
:lexpr
:lex[pr][!] {expr}
Same as :cexpr, except the location list for the
current window is used instead of the quickfix list.:cgete
:cgetexpr
:cgete[xpr] {expr}
Create a quickfix list using the result of {expr}
.
Just like :cexpr, but don't jump to the first error.:lgete
:lgetexpr
:lgete[xpr] {expr}
Same as :cgetexpr, except the location list for the
current window is used instead of the quickfix list.:cadde
:caddexpr
:cadde[xpr] {expr}
Evaluate {expr}
and add the resulting lines to the
current quickfix list. If a quickfix list is not
present, then a new list is created. The current
cursor position will not be changed. See :cexpr for
more information.
Example::g/mypattern/caddexpr expand("%") .. ":" .. line(".") .. ":" .. getline(".")
:lad
:addd
:laddexpr
:lad[dexpr] {expr}
Same as ":caddexpr", except the location list for the
current window is used instead of the quickfix list.:cl
:clist
:cl[ist] [from] [, [to]]
List all errors that are valid quickfix-valid.
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 :filter command can be used to display only the
quickfix entries matching a supplied pattern. The
pattern is matched against the filename, module name,
pattern and text of the entry.{count}
valid errors. This
is similar to ":clist from from+count", where "from"
is the current error position.{count}
error lines. This
is useful to see unrecognized lines after the current
one. For example, if ":clist" shows:
:lli
:llist
Same as ":clist", except the location list for the
current window is used instead of the quickfix list.QuickFixCmdPost-example
When 'encoding' differs from the locale, the error messages may have a
different encoding from what Vim is using. To convert the messages you can
use this code:function QfMakeConv() let qflist = getqflist() for i in qflist let i.text = iconv(i.text, "cp936", "utf-8") endfor call setqflist(qflist) endfunction au QuickfixCmdPost make call QfMakeConv()Another option is using 'makeencoding'.
quickfix-title
Every quickfix and location list has a title. By default the title is set to
the command that created the list. The getqflist() and getloclist()
functions can be used to get the title of a quickfix and a location list
respectively. The setqflist() and setloclist() functions can be used to
modify the title of a quickfix and location list respectively. Examples:call setqflist([], 'a', {'title' : 'Cmd output'}) echo getqflist({'title' : 1}) call setloclist(3, [], 'a', {'title' : 'Cmd output'}) echo getloclist(3, {'title' : 1})
quickfix-index
When you jump to a quickfix/location list entry using any of the quickfix
commands (e.g. :cc, :cnext, :cprev, etc.), that entry becomes the
currently selected entry. The index of the currently selected entry in a
quickfix/location list can be obtained using the getqflist()/getloclist()
functions. Examples:echo getqflist({'idx' : 0}).idx echo getqflist({'id' : qfid, 'idx' : 0}).idx echo getloclist(2, {'idx' : 0}).idx
call setqflist([], 'a', {'idx' : 12}) call setqflist([], 'a', {'id' : qfid, 'idx' : 7}) call setloclist(1, [], 'a', {'idx' : 7})
quickfix-size
You can get the number of entries (size) in a quickfix and a location list
using the getqflist() and getloclist() functions respectively. Examples:echo getqflist({'size' : 1}) echo getloclist(5, {'size' : 1})
quickfix-context
Any Vim type can be associated as a context with a quickfix or location list.
The setqflist() and the setloclist() functions can be used to associate a
context with a quickfix and a location list respectively. The getqflist()
and the getloclist() functions can be used to retrieve the context of a
quickfix and a location list respectively. This is useful for a Vim plugin
dealing with multiple quickfix/location lists.
Examples:let somectx = {'name' : 'Vim', 'type' : 'Editor'} call setqflist([], 'a', {'context' : somectx}) echo getqflist({'context' : 1}) let newctx = ['red', 'green', 'blue'] call setloclist(2, [], 'a', {'id' : qfid, 'context' : newctx}) echo getloclist(2, {'id' : qfid, 'context' : 1})
quickfix-parse
You can parse a list of lines using 'errorformat' without creating or
modifying a quickfix list using the getqflist() function. Examples:echo getqflist({'lines' : ["F1:10:Line10", "F2:20:Line20"]}) echo getqflist({'lines' : systemlist('grep -Hn quickfix *')})This returns a dictionary where the "items" key contains the list of quickfix entries parsed from lines. The following shows how to use a custom 'errorformat' to parse the lines without modifying the 'errorformat' option:
echo getqflist({'efm' : '%f#%l#%m', 'lines' : ['F1#10#Line']})
:cdo
:cdo[!] {cmd}
Execute {cmd}
in each valid entry in the quickfix list.
It works like doing this::cfirst :{cmd} :cnext :{cmd} etc.
{cmd}
can contain '|' to concatenate several commands.:10,$cdo cmd
:cfdo
:cfdo[!] {cmd}
Execute {cmd}
in each file in the quickfix list.
It works like doing this::cfirst :{cmd} :cnfile :{cmd} etc.
:cdo
.:ldo
:ld[o][!] {cmd}
Execute {cmd}
in each valid entry in the location list
for the current window.
It works like doing this::lfirst :{cmd} :lnext :{cmd} etc.
:cdo
.:lfdo
:lfdo[!] {cmd}
Execute {cmd}
in each file in the location list for
the current window.
It works like doing this::lfirst :{cmd} :lnfile :{cmd} etc.
:ldo
.cfilter-plugin
:Cfilter
:Lfilter
If you have too many entries in a quickfix list, you can use the cfilter
plugin to reduce the number of entries. Load the plugin with:packadd cfilterThen you can use the following commands to filter a quickfix/location list:
:Cfilter[!] /{pat}/ :Lfilter[!] /{pat}/The :Cfilter command creates a new quickfix list from the entries matching
{pat}
in the current quickfix list. {pat}
is a Vim regular-expression
pattern. Both the file name and the text of the entries are matched against
{pat}
. If the optional ! is supplied, then the entries not matching {pat}
are
used. The pattern can be optionally enclosed using one of the following
characters: ', ", /. If the pattern is empty, then the last used search
pattern is used.quickfix-buffer
The window will contain a special buffer, with
'buftype' equal to "quickfix". Don't change this!
The window will have the w:quickfix_title variable set
which will indicate the command that produced the
quickfix list. This can be used to compose a custom
status line if the value of 'statusline' is adjusted
properly. Whenever this buffer is modified by a
quickfix command or function, the b:changedtick
variable is incremented. You can get the number of
this buffer using the getqflist() and getloclist()
functions by passing the "qfbufnr" item. For a
location list, this buffer is wiped out when the
location list is removed.:lop
:lopen
:lop[en] [height] Open a window to show the location list for the
current window. Works only when the location list for
the current window is present. You can have more than
one location window opened at a time. Otherwise, it
acts the same as ":copen".:cw
:cwindow
:cw[indow] [height] Open the quickfix window when there are recognized
errors. If the window is already open and there are
no recognized errors, close the window.:lw
:lwindow
:lw[indow] [height] Same as ":cwindow", except use the window showing the
location list for the current window.:cbo
:cbottom
:cbo[ttom] Put the cursor in the last line of the quickfix window
and scroll to make it visible. This is useful for
when errors are added by an asynchronous callback.
Only call it once in a while if there are many
updates to avoid a lot of redrawing.:lbo
:lbottom
:lbo[ttom] Same as ":cbottom", except use the window showing the
location list for the current window.:botright cwindowYou can move the window around with window-moving commands. For example, to move it to the top:
CTRL-W
K
The 'winfixheight' option will be set, which means that the window will mostly
keep its height, ignoring 'winheight' and 'equalalways'. You can change the
height manually (e.g., by dragging the status line above it with the mouse).:hi QuickFixLine ctermbg=Yellow guibg=YellowYou can use ":.cc" to jump to the error under the cursor. Hitting the
<Enter>
key or double-clicking the mouse on a line has the same
effect. The file containing the error is opened in the window above the
quickfix window. If there already is a window for that file, it is used
instead. If the buffer in the used window has changed, and the error is in
another file, jumping to the error will fail. You will first have to make
sure the window contains a buffer which can be abandoned.CTRL-W_<Enter>
CTRL-W_<CR>
You can use CTRL-W
<Enter>
to open a new window and jump to the error there.au BufReadPost quickfix setlocal modifiable \ | silent exe 'g/^/s//\=line(".") .. " "/' \ | setlocal nomodifiableThis prepends the line number to each line. Note the use of "\=" in the substitute string of the ":s" command, which is used to evaluate an expression. The BufWinEnter event is also triggered, again using "quickfix" for the buffer name.
location-list-window
The location list window displays the entries in a location list. When you
open a location list window, it is created below the current window and
displays the location list for the current window. The location list window
is similar to the quickfix window, except that you can have more than one
location list window open at a time. When you use a location list command in
this window, the displayed location list is used.quickfix-window-ID
You can use the getqflist() and getloclist() functions to obtain the
window ID of the quickfix window and location list window respectively (if
present). Examples:echo getqflist({'winid' : 1}).winid echo getloclist(2, {'winid' : 1}).winid
getqflist-examples
The getqflist() and getloclist() functions can be used to get the various
attributes of a quickfix and location list respectively. Some examples for
using these functions are below:
" get the title of the current quickfix list :echo getqflist({'title' : 0}).title " get the identifier of the current quickfix list :let qfid = getqflist({'id' : 0}).id " get the identifier of the fourth quickfix list in the stack :let qfid = getqflist({'nr' : 4, 'id' : 0}).id " check whether a quickfix list with a specific identifier exists :if getqflist({'id' : qfid}).id == qfid " get the index of the current quickfix list in the stack :let qfnum = getqflist({'nr' : 0}).nr " get the items of a quickfix list specified by an identifier :echo getqflist({'id' : qfid, 'items' : 0}).items " get the number of entries in a quickfix list specified by an id :echo getqflist({'id' : qfid, 'size' : 0}).size " get the context of the third quickfix list in the stack :echo getqflist({'nr' : 3, 'context' : 0}).context " get the number of quickfix lists in the stack :echo getqflist({'nr' : '$'}).nr " get the number of times the current quickfix list is changed :echo getqflist({'changedtick' : 0}).changedtick " get the current entry in a quickfix list specified by an identifier :echo getqflist({'id' : qfid, 'idx' : 0}).idx " get all the quickfix list attributes using an identifier :echo getqflist({'id' : qfid, 'all' : 0}) " parse text from a List of lines and return a quickfix list :let myList = ["a.java:10:L10", "b.java:20:L20"] :echo getqflist({'lines' : myList}).items " parse text using a custom 'efm' and return a quickfix list :echo getqflist({'lines' : ['a.c#10#Line 10'], 'efm':'%f#%l#%m'}).items " get the quickfix list window id :echo getqflist({'winid' : 0}).winid " get the quickfix list window buffer number :echo getqflist({'qfbufnr' : 0}).qfbufnr " get the context of the current location list :echo getloclist(0, {'context' : 0}).context " get the location list window id of the third window :echo getloclist(3, {'winid' : 0}).winid " get the location list window buffer number of the third window :echo getloclist(3, {'qfbufnr' : 0}).qfbufnr " get the file window id of a location list window (winnr: 4) :echo getloclist(4, {'filewinid' : 0}).filewinid
setqflist-examples
The setqflist() and setloclist() functions can be used to set the various
attributes of a quickfix and location list respectively. Some examples for
using these functions are below:
" create an empty quickfix list with a title and a context :let t = 'Search results' :let c = {'cmd' : 'grep'} :call setqflist([], ' ', {'title' : t, 'context' : c}) " set the title of the current quickfix list :call setqflist([], 'a', {'title' : 'Mytitle'}) " change the current entry in the list specified by an identifier :call setqflist([], 'a', {'id' : qfid, 'idx' : 10}) " set the context of a quickfix list specified by an identifier :call setqflist([], 'a', {'id' : qfid, 'context' : {'val' : 100}}) " create a new quickfix list from a command output :call setqflist([], ' ', {'lines' : systemlist('grep -Hn main *.c')}) " parse text using a custom efm and add to a particular quickfix list :call setqflist([], 'a', {'id' : qfid, \ 'lines' : ["a.c#10#L10", "b.c#20#L20"], 'efm':'%f#%l#%m'}) " add items to the quickfix list specified by an identifier :let newItems = [{'filename' : 'a.txt', 'lnum' : 10, 'text' : "Apple"}, \ {'filename' : 'b.txt', 'lnum' : 20, 'text' : "Orange"}] :call setqflist([], 'a', {'id' : qfid, 'items' : newItems}) " empty a quickfix list specified by an identifier :call setqflist([], 'r', {'id' : qfid, 'items' : []}) " free all the quickfix lists in the stack :call setqflist([], 'f') " set the title of the fourth quickfix list :call setqflist([], 'a', {'nr' : 4, 'title' : 'SomeTitle'}) " create a new quickfix list at the end of the stack :call setqflist([], ' ', {'nr' : '$', \ 'lines' : systemlist('grep -Hn class *.java')}) " create a new location list from a command output :call setloclist(0, [], ' ', {'lines' : systemlist('grep -Hn main *.c')}) " replace the location list entries for the third window :call setloclist(3, [], 'r', {'items' : newItems})
:colder
:col
E380
:col[der] [count] Go to older error list. When [count] is given, do
this [count] times. When already at the oldest error
list, an error message is given.:lolder
:lol
:lol[der] [count] Same as :colder
, except use the location list for
the current window instead of the quickfix list.:cnewer
:cnew
E381
:cnew[er] [count] Go to newer error list. When [count] is given, do
this [count] times. When already at the newest error
list, an error message is given.:lnewer
:lnew
:lnew[er] [count] Same as :cnewer
, except use the location list for
the current window instead of the quickfix list.:chistory
:chi
:[count]chi[story] Show the list of error lists. The current list is
marked with ">". The output looks like:error list 1 of 3; 43 errors :make > error list 2 of 3; 0 errors :helpgrep tag error list 3 of 3; 15 errors :grep ex_help *.c
" Make the 4th quickfix list current :4chistory
echo getqflist({'nr' : '$'}).nr echo getloclist(3, {'nr' : '$'}).nrTo get the number of the current list in the stack:
echo getqflist({'nr' : 0}).nr
:mak
:make
:mak[e][!] [arguments] 1. All relevant QuickFixCmdPre autocommands are
executed.
2. If the 'autowrite' option is on, write any changed
buffers
3. An errorfile name is made from 'makeef'. If
'makeef' doesn't contain "##", and a file with this
name already exists, it is deleted.
4. 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).
5. The errorfile is read using 'errorformat'.
6. All relevant QuickFixCmdPost autocommands are
executed. See example below.
7. If [!] is not given the first error is jumped to.
8. The errorfile is deleted.
9. You can now move through the errors with commands
like :cnext and :cprevious, see above.
This command does not accept a comment, any "
characters are considered part of the arguments.
If the encoding of the program output differs from the
'encoding' option, you can use the 'makeencoding'
option to specify the encoding.:lmak
:lmake
:lmak[e][!] [arguments]
Same as ":make", except the location list for the
current window is used instead of the quickfix list.{shellpipe}
{errorfile}
".{makeprg}
is the string given with the 'makeprg' option. Any command can be
used, not just "make". Characters '%' and '#' are expanded as usual on a
command-line. You can use "%<" to insert the current file name without
extension, or "#<" to insert the alternate file name without extension, for
example::set makeprg=make\ #<.o[arguments] is anything that is typed after ":make".
{shellpipe}
is the 'shellpipe' option.
{errorfile}
is the 'makeef' option, with ## replaced to make it unique.{makeprg}
if the
command needs some additional characters after its arguments. The $* is
replaced then by all arguments. Example::set makeprg=latex\ \\\\nonstopmode\ \\\\input\\{$*}or simpler
:let &mp = 'latex \\nonstopmode \\input\{$*}'"$*" can be given multiple times, for example:
:set makeprg=gcc\ -o\ $*\ $*The 'shellpipe' option defaults to "2>&1| tee" for Win32. This means that the output of the compiler is saved in a file and not shown on the screen directly. For Unix "| tee" is used. The compiler output is shown on the screen and saved in a file the same time. Depending on the shell used "|& tee" or "2>&1| tee" is the default, so stderr output will be included.
{errorfile}
part will be omitted. This is useful
for compilers that write to an errorfile themselves.function QfMakeConv() let qflist = getqflist() for i in qflist let i.text = iconv(i.text, "cp936", "utf-8") endfor call setqflist(qflist) endfunction au QuickfixCmdPost make call QfMakeConv()(Example by Faque Cheng) Another option is using 'makeencoding'.
command! -nargs=+ NewGrep execute 'silent grep! <args>' | copen 425.1 Using Vim's internal grep
:vim
:vimgrep
E682
E683
:vim[grep][!] /{pattern}/[g][j][f] {file}
...
Search for {pattern}
in the files {file}
... and set
the error list to the matches. Files matching
'wildignore' are ignored; files in 'suffixes' are
searched last.{pattern}
is a Vim search pattern. Instead of
enclosing it in / any non-ID character (see
'isident') can be used, so long as it does not
appear in {pattern}
.
'ignorecase' applies. To overrule it put /\c in the
pattern to ignore case or /\C to match case.
'smartcase' is not used.
If {pattern}
is empty (e.g. // is specified), the last
used search pattern is used. last-pattern{pattern}
is treated as a literal string
instead of a regular expression. See
fuzzy-matching for more information about fuzzy
matching strings.:vimgrep /an error/ *.c :vimgrep /\<FileName\>/ *.h include/* :vimgrep /myfunc/ **/*.c
{pattern}
{file}
...
Like above, but instead of enclosing the pattern in a
non-ID character use a white space separated pattern.
The pattern must start with an ID character.
Example::vimgrep Error *.c
:lv
:lvimgrep
:lv[imgrep][!] /{pattern}/[g][j][f] {file}
...
:lv[imgrep][!] {pattern}
{file}
...
Same as ":vimgrep", except the location list for the
current window is used instead of the quickfix list.:vimgrepa
:vimgrepadd
:vimgrepa[dd][!] /{pattern}/[g][j][f] {file}
...
:vimgrepa[dd][!] {pattern}
{file}
...
Just like ":vimgrep", but instead of making a new list
of errors the matches are appended to the current
list.:lvimgrepa
:lvimgrepadd
:lvimgrepa[dd][!] /{pattern}/[g][j][f] {file}
...
:lvimgrepa[dd][!] {pattern}
{file}
...
Same as ":vimgrepadd", except the location list for
the current window is used instead of the quickfix
list.:gr
:grep
:gr[ep][!] [arguments] Just like ":make", but use 'grepprg' instead of
'makeprg' and 'grepformat' instead of 'errorformat'.
When 'grepprg' is "internal" this works like
:vimgrep. Note that the pattern needs to be
enclosed in separator characters then.
If the encoding of the program output differs from the
'encoding' option, you can use the 'makeencoding'
option to specify the encoding.:lgr
:lgrep
:lgr[ep][!] [arguments] Same as ":grep", except the location list for the
current window is used instead of the quickfix list.:grepa
:grepadd
:grepa[dd][!] [arguments]
Just like ":grep", but instead of making a new list of
errors the matches are appended to the current list.
Example::call setqflist([]) :bufdo grepadd! something %
:silent argdo try \ | grepadd! something % \ | catch /E480:/ \ | endtry"
:lgrepa
:lgrepadd
:lgrepa[dd][!] [arguments]
Same as ":grepadd", except the location list for the
current window is used instead of the quickfix list.:grep foo *.cWill search all files with the .c extension for the substring "foo". The arguments to :grep are passed straight to the "grep" program, so you can use whatever options your "grep" supports.
:set grepprg=lid\ -Rgrep\ -s :set grepformat=%f:%l:%mthen
:grep (regexp)works just as you'd expect. (provided you remembered to mkid first :)
:vimgrep /\<read_file\>/ *.cYou use ":cn" to go along the list of matches and add the argument. At one place you have to get the new argument from a higher level function msg(), and need to change that one too. Thus you use:
:vimgrep /\<msg\>/ *.cWhile changing the msg() functions, you find another function that needs to get the argument from a higher level. You can again use ":vimgrep" to find these functions. Once you are finished with one function, you can use
:colderto go back to the previous one.
:comp
:compiler
E666
:comp[iler][!] {name}
Set options to work with compiler {name}
.
Without the "!" options are set for the
current buffer. With "!" global options are
set.
If you use ":compiler foo" in "file.foo" and
then ":compiler! bar" in another buffer, Vim
will keep on using "foo" in "file.foo".:compiler
local options are set, for :compiler!
global options.
current_compiler
To support older Vim versions, the plugins always use "current_compiler" and
not "b:current_compiler". What the command actually does is the following:let dotnet_errors_only = v:true let dotnet_show_project_file = v:false compiler dotnet
let g:javac_makeprg_params = "-Xlint:all -encoding utf-8"
b:groff_compiler_args
or g:groff_compiler_args
. The language
argument
passed to groff is set using 'spelllang'; it can be overridden by setting
b:groff_compiler_lang
. The default enconding is UTF-8
and can be changed
by setting b:groff_compiler_encoding
or g:groff_compiler_encoding
.:make html --self-contained
.
b:pandoc_compiler_args
or g:pandoc_compiler_args
.
--from
argument is an educated guess using the buffer file type;
it can be overridden by setting b:pandoc_compiler_from
.
The --metadata lang
argument is set using 'spelllang';
If --from=markdown
is assumed and no title set in a title header or
YAML block, then the filename (without extension) is used as the title.let g:perl_compiler_force_warnings = 0
*TeX
files with make, and the makefile does the right work. In this case
compiler sets 'errorformat' for *TeX
output and leaves 'makeprg' untouched. If
neither "Makefile" nor "makefile" is found, the compiler will not use make.
You can force the compiler to ignore makefiles by defining
b:tex_ignore_makefile or g:tex_ignore_makefile variable (they are checked for
existence only).:let b:tex_flavor = 'amstex' :compiler tex
:make mypaperNote that you must specify a name of the file to process as an argument (to process the right file when editing \input-ed or \include-ed file; portable solution for substituting % for no arguments is welcome). This is not in the semantics of make, where you specify a target, not source, but you may specify filename without extension ".tex" and mean this as "make filename.dvi or filename.pdf or filename.some_result_extension according to compiler".
g:typst_cmd
By default Vim will use "typst" as the command to run the Typst compiler. This
can be changed by setting the g:typst_cmd variable:let g:typst_cmd = "/path/to/other/command"
errorformat
E372
E373
E374
E375
E376
E377
E378
The 'errorformat' option specifies a list of formats that are recognized. The
first format that matches with an error message is used. You can add several
formats for different messages your compiler produces, or even entries for
multiple compilers. See efm-entries.:make
and :grep
output all NUL characters are
replaced with SOH (0x01).<tab>
is 1
character column)
%v virtual column number (finds a number representing
screen column of the error (1 <tab>
== 8 screen
columns))
%k end column number (finds a number representing
the character column of the error, byte index, or a
number representing screen end column of the error if
it's used with %v)
%t error type (finds a single character):
e - error message
w - warning message
i - info message
n - note message
%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
%p pointer line (finds a sequence of '-', '.', ' ' or
tabs and uses the length for the column number)
%*{conv} any scanf non-assignable conversion
%% the single '%' character
%s search text (finds a string)^or
---------^to indicate the column of the error. This is to be used in a multi-line error message. See errorformat-javac for a useful example.
E379
%D "enter directory" format string; expects a following
%f that finds the directory name
%X "leave directory" format string; expects following %ferrorformat-multi-line
:set efm=%EError\ %n,%Cline\ %l,%Ccolumn\ %c,%Z%mAnd the :clist error message generated for this error is:
:set efm=%C\ %.%#,%A\ \ File\ \"%f\"\\,\ line\ %l%.%#,%Z%[%^\ ]%\\@=%mNote that the %C string is given before the %A here: since the expression ' %.%#' (which stands for the regular expression ' .*') matches every line starting with a space, followed by any characters to the end of the line, it also hides line 7 which would trigger a separate error message otherwise. Error format strings are always parsed pattern by pattern until the first match occurs.
efm-%>
The %> item can be used to avoid trying patterns that appear earlier in
'errorformat'. This is useful for patterns that match just about anything.
For example, if the error looks like this::set efm=xxx,%E%>Error in line %l of %f:,%Z%mWhere "xxx" has a pattern that would also match the second line.
setlocal efm=aa,bb,cc,dd,eeWhere aa, bb, etc. are error format strings. Each line of the error file will be matched to the pattern aa, then bb, then cc, etc. Just because cc matched the previous error line does _not_ mean that dd will be tried first on the current line, even if cc and dd are multi-line errorformat strings.
errorformat-separate-filename
:set efm=%+P[%f],(%l\\,%c)%*[\ ]%t%*[^:]:\ %m,%-QA call of :clist writes them accordingly with their correct filenames:
{"file1" {"file2" error1} error2 {"file3" error3 {"file4" error4 error5}}}
efm-ignore
efm-entries
quickfix-valid
:set mp=make\ \\\|&\ error_filterThe backslashes before the pipe character are required to avoid it to be recognized as a command separator. The backslash before each space is required for the set command.
{target}
in {dir}
". The
special problem here is that it doesn't print information on leaving the
directory and that it doesn't print the absolute path.errorformat-Jikes
Jikes(TM), a source-to-bytecode Java compiler published by IBM Research,
produces simple multi-line error messages.:set efm=%A%f:%l:%c:%*\\d:%*\\d:, \%C%*\\s%trror:%m, \%+C%*[^:]%trror:%m, \%C%*\\s%tarning:%m, \%C%m
:setl efm=%f:%l:%v:%*\\d:%*\\d:%*\\s%m
errorformat-javac
This 'errorformat' has been reported to work well for javac, which outputs a
line with "^" to indicate the column of the error::setl efm=%A%f:%l:\ %m,%-Z%p^,%-C%.%#or:
:setl efm=%A%f:%l:\ %m,%+Z%p^,%+C%.%#,%-G%.%#
:setl errorformat=%Z%f:%l:\ %m,%A%p^,%-G%*[^sl]%.%# :setl makeprg=javac\ %:S\ 2>&1\ \\\|\ vim-javac-filterYou need to put the following in "vim-javac-filter" somewhere in your path (e.g., in ~/bin) and make it executable:
#!/bin/sed -f /\^$/s/\t/\ /g;/:[0-9]\+:/{h;d};/^[ \t]*\^/G;In English, that sed script:
errorformat-ant
For ant (https://jakarta.apache.org/) the above errorformat has to be modified
to honour the leading [javac] in front of each javac output line::set efm=%A\ %#[javac]\ %f:%l:\ %m,%-Z\ %#[javac]\ %p^,%-C%.%#The 'errorformat' can also be configured to handle ant together with either javac or jikes. If you're using jikes, you should tell ant to use jikes' +E command line switch which forces jikes to generate one-line error messages. This is what the second line (of a build.xml file) below does:
<property name = "build.compiler" value = "jikes"/> <property name = "build.compiler.emacs" value = "true"/>The 'errorformat' which handles ant with both javac and jikes is:
:set efm=\ %#[javac]\ %#%f:%l:%c:%*\\d:%*\\d:\ %t%[%^:]%#:%m, \%A\ %#[javac]\ %f:%l:\ %m,%-Z\ %#[javac]\ %p^,%-C%.%#
errorformat-jade
parsing jade (see http://www.jclark.com/) errors is simple::set efm=jade:%f:%l:%c:%t:%m
errorformat-LaTeX
The following is an example how an 'errorformat' string can be specified
for the (La)TeX typesetting system which displays error messages over
multiple lines. The output of ":clist" and ":cc" etc. commands displays
multi-lines in a single line, leading white space is removed.
It should be easy to adopt the above LaTeX errorformat to any compiler output
consisting of multi-line errors.:set makeprg=latex\ \\\\nonstopmode\ \\\\input\\{$*}
:set efm=%E!\ LaTeX\ %trror:\ %m, \%E!\ %m,
\%+WLaTeX\ %.%#Warning:\ %.%#line\ %l%.%#, \%+W%.%#\ at\ lines\ %l--%*\\d, \%WLaTeX\ %.%#Warning:\ %m,
\%Cl.%l\ %m, \%+C\ \ %m., \%+C%.%#-%.%#, \%+C%.%#[]%.%#, \%+C[]%.%#, \%+C%.%#%[{}\\]%.%#, \%+C<%.%#>%.%#, \%C\ \ %m,
\%-GSee\ the\ LaTeX%m, \%-GType\ \ H\ <return>%m, \%-G\ ...%.%#, \%-G%.%#\ (C)\ %.%#, \%-G(see\ the\ transcript%.%#),
\%-G\\s%#,
\%+O(%f)%r,
\%+P(%f%r, \%+P\ %\\=(%f%r, \%+P%*[^()](%f%r, \%+P[%\\d%[^()]%#(%f%r,
\%+Q)%r, \%+Q%*[^()])%r, \%+Q[%\\d%*[^()])%rNote that in some cases file names in the LaTeX output log cannot be parsed properly. The parser might have been messed up by unbalanced parentheses then. The above example tries to catch the most relevant cases only. You can customize the given setting to suit your own purposes, for example, all the annoying "Overfull ..." warnings could be excluded from being recognized as an error. Alternatively to filtering the LaTeX compiler output, it is also possible to directly read the
*.log
file that is produced by the [La]TeX compiler.
This contains even more useful information about possible error causes.
However, to properly parse such a complex file, an external filter should
be used. See the description further above how to make such a filter known
by Vim.<filename>|<lnum> col <col>|<text>
" create a quickfix list from v:oldfiles call setqflist([], ' ', {'lines' : v:oldfiles, 'efm' : '%f', \ 'quickfixtextfunc' : 'QfOldFiles'}) func QfOldFiles(info) " get information about a range of quickfix entries let items = getqflist({'id' : a:info.id, 'items' : 1}).items let l = [] for idx in range(a:info.start_idx - 1, a:info.end_idx - 1) " use the simplified file name call add(l, fnamemodify(bufname(items[idx].bufnr), ':p:.')) endfor return l endfunc