exists in the
identified directory. If not, it is searched in all other directories of the
directory stack (NOT the directory subtree!). If it is still not found, it is
assumed that it is in Vim's current directory.
There are limitations in this algorithm. These examples assume that make just
prints information about entering a directory in the form "Making all in dir".
1) Assume you have following directories and files:
./dir1
./dir1/file1.c
./file1.c
If make processes the directory "./dir1" before the current directory and
there is an error in the file "./file1.c", you will end up with the file
"./dir1/file.c" loaded by Vim.
This can only be solved with a "leave directory" message.
2) Assume you have following directories and files:
./dir1
./dir1/dir2
./dir2
You get the following:
Make output Directory interpreted by Vim
------------------------ ----------------------------
Making all in dir1 ./dir1
Making all in dir2 ./dir1/dir2
Making all in dir2 ./dir1/dir2
This can be solved by printing absolute directories in the "enter directory"
message or by printing "leave directory" messages.
To avoid this problem, ensure to print absolute directory names and "leave
directory" messages.
Examples for Makefiles:
Unix:
libs:
for dn in $(LIBDIRS); do \
(cd $$dn; echo "Entering dir '$$(pwd)'"; make); \
echo "Leaving dir"; \
done
Add
%DEntering\ dir\ '%f',%XLeaving\ dir
to your 'errorformat' to handle the above output.
Note that Vim doesn't check if the directory name in a "leave directory"
messages is the current directory. This is why you could just use the message
"Leaving dir".
=============================================================================
9. Specific error file formats *errorformats*
*errorformat-Jikes*
Jikes(TM), a source-to-bytecode Java compiler published by IBM Research,
produces simple multi-line error messages.
An 'errorformat' string matching the produced messages is shown below.
The following lines can be placed in the user's |init.vim| to overwrite Vim's
recognized default formats, or see |:set+=| how to install this format
additionally to the default. >
:set efm=%A%f:%l:%c:%*\\d:%*\\d:,
\%C%*\\s%trror:%m,
\%+C%*[^:]%trror:%m,
\%C%*\\s%tarning:%m,
\%C%m
<
Jikes(TM) produces a single-line error message when invoked with the option
"+E", and can be matched with the following: >
: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%.%#
<
Here is an alternative from Michael F. Lamb for Unix that filters the errors
first: >
:setl errorformat=%Z%f:%l:\ %m,%A%p^,%-G%*[^sl]%.%#
:setl makeprg=javac\ %:S\ 2>&1\ \\\|\ vim-javac-filter
You 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:
- Changes single tabs to single spaces and
- Moves the line with the filename, line number, error message to just after
the pointer line. That way, the unused error text between doesn't break
vim's notion of a "multi-line message" and also doesn't force us to include
it as a "continuation of a multi-line message."
*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