vimfilterformatsetting

VIM quick fix: How to filter some text from error format string?


For example, my build log is something like:

[Server01:/sourceroot/src/test01.cpp:3]This is an macro error.

I hope to set error format to detect

%f=src/test01.cpp, %l=3

So how to filter out the "Server01:/sourceroot/" string in my "set efm=" setting in .vimrc files?


Solution

  • Assuming /sourceroot/ is just the first component of the path:

    let &errorformat = '[%[%^/]%#:/%[%^/]%#/%f:%l]%m'
    

    However, it's probably easier to re-format the initial message before parsing it with errorformat.