Try :h :cfile or :h :cgetfile
: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
The solution is described in the manual:
If you just want a highlighted message use :echohl.
And to get a beep: :exe "normal \<Esc>"
function! PrintError(msg) abort
execute 'normal! \<Esc>'
Try the following:
The final %-G%.%# acts as a "catch all" clause, that ignores all lines, that are not matched by previous expressions.
The following should also work:
:set errorformat=%A%f:%l:%c:%m,%-G\\s%#,%-G%*\\d\ problem%.%#
%-G\\s%# ignores all lines that contains zero or more whitespaces. This ...
As Tumbler41 notes, isfname has to be turned on:
If "%f" is followed by a '%' or a backslash, it will look for a sequence of 'isfname' characters.
I had no luck inserting a % (%: is an invalid format), but I succeeded with a backslash. This requires a second backslash to escape the first.
:set efm=%f\\:%l:\ %
Then set efm shows the single backslash:
The issue is that the text you want to see in the message field of the quickfix list is disconnected in the original output:
error: cannot format /home/user/repo/src/file1.py: Cannot parse: 2:5: some source code here
^^^^^^^^^^^^^ ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^
Try to filter the errors first, with some script, ...
First thing I notice is that you have quotes in there. When using set everything after the = symbol is set to the value.
Since errorformat has spaces and backslashes my preferred way to set it is with let and single-quoted strings, then string concatenation so I can break it up into more easily parsed lines.
let &errorformat =
\ '%*[^"]"%f"%*\D%l: ...
Disclaimer: I have never used errorformat before.
Edit: Deleted pointless stuff that was a mis-understanding of the question.
One other note. Earlier in the help doc it states:
If "%f" is followed by a '%' or a
backslash, it will look for a sequence of 'isfname' characters.
Since yours doesn't, maybe that's why it can match a space?
As @JigglyNaga ...
I'm not aware of any built-in mechanism of jumping to the location of an error in the error log.
However, the default behaviour of errorformat is to include all of the makeprg output, so context can be seen in the quickfix window itself.
The errorformat described in :help errorformat-LaTeX includes a number of patterns specifically intended to hide ...
As suggested by CrashNeb, %\\@= means \\@= as in regexp, which does a lookup ahead without actually consuming the characters.
%[%^\ ], is [^\ ] (don't match \ or ) but escaped ([ and ^ needs to be escaped using %.
So, %Z%[%^\ ]%\\@=%m means if the line doesn't start with a space or \, end the multiline (%Z) errors and use THE FULL LINE as a the message. ...
After going through other options, I realised that the default of quickfix is to capture all the output and use %- prefix to skip any lines
after modifying the errorformat to
CompilerSet errorformat=%.%#\ at\ %.%#(%f:%l:%c),%-G%.%#
it worked. But this worked only in vanilla vim - compiler,make combo.
I was using this as part of vim-dispatch and neo-vim ...
There are a few minor issues with most of your lines ignoring specific patterns.
%-G%Oh no!\ %m : You have an extra % there, turning the first character into a %O (a command to overread the matched part) rather than a literal O. You also have a trailing space there, so it would only match a line with a space at the end! You can fix that to %-GOh no!\ %m. ...
As Biggybi notes, there may be a misunderstanding as I'm not sure if you want the quickfix window to correctly interpret the output of latexmk or you want it to display the errors in a different way. If it's the latter, then you'll want to look at :h quickfix-window-function which enables you to customise this, although note that it is still a single line ...
I think you misunderstand what 'errorformat' does.
It's not "please display errors like so", rather "here's what errors look like, please find them".
More precisely, each line of the output of makeprg is matched against each member errorformat.
Your example, %f:%l:%c:%m, works for an output that looks like:
file:3:2:this is an error ...
Try to change your errorformat to
setlocal efm=%E%f:%l:%c:,%E%f:%l:,%C,%C%p%*[0123456789^],%ZError:\ %m,%C%.%#
the difference is in separator between LINE and COLUMN. You have %l.%c, but looks like it should be %l:%c
there are some problems with autocommands we cannot see from your example (but vim error clearly states it)
if you do only set efm=..., set ...
After all I solved this problem using sed linux utilit. My solution:
some-cli | sed "s/\x1b\[[0-9;]*m//g" | some-errorformat-vim-tool
where sed "s/\x1b\[[0-9;]*m//g" remove all ansi-codes.
This answer helped my: Can Vim interpret terminal color escape codes?
Afaik 'efm' of vim cannot handle this situation, i.e. %l matches only a sequence of digits with no spaces or linebreaks between the digits. Vim help discusses in more detail a possible value of'efm' for LaTeX but does not answer this question:
Maybe you can ask this on the issue tracker of vim or the vim_dev mailing list to get an ...
set errorformat=[%t%*\\a]\ %f(%l):\ %m
The pattern \a\+, is equivalent to %*\\a according to :h errorformat.
However you may want to look to see if Vim already supports your compiler of choice. Do :compiler then tab complete or use <c-d> to get a list of known compilers.
I was able to eliminate the escape codes by changing the -fdiagnostics-color option in gcc. So this answers my first question (the escape codes in vim's make output were caused by a gcc option that colorizes its output, and had nothing to do with vim).
I (mostly) answered my second question too. I was using this errorformat:
set errorformat =%E%f:%l:%c:\ %...
You're asking to set up a search from the quickfix which as far as I know isn't possible via errorformat. However you could write a function to do it and then map that function to a keymap or a command or something.
let l:matches = matchlist(getline('.'), '^[^:]*.o:\([^:]*\):.*'