vimmultilineerrorformat

Multiline errorformat in vim


I'm trying to match on C error messages like this:

gmake[1]: Entering directory `/project/swbuild45/ethanl/swfeature_int/pkt'
...
sw/se/xc/bsd/routing/rib/src/rib_bfd_thrd.c: In function 'bfd_delete_constituent_session':
sw/se/xc/bsd/routing/rib/src/rib_bfd_thrd.c:3654: error: 'bfd_ses' undeclared (first use in this function)
sw/se/xc/bsd/routing/rib/src/rib_bfd_thrd.c:3654: error: (Each undeclared identifier is reported only once
sw/se/xc/bsd/routing/rib/src/rib_bfd_thrd.c:3654: error: for each function it appears in.)
sw/se/xc/bsd/routing/rib/src/rib_bfd_thrd.c:3654: error: expected ';' before 'sion_cst'
sw/se/xc/bsd/routing/rib/src/rib_bfd_thrd.c:3663: error: 'dbl_dequ' undeclared (first use in this function)
sw/se/xc/bsd/routing/rib/src/rib_bfd_thrd.c:3663: error: expected ';' before 'eue'
...
gmake[1]: Leaving directory `/project/swbuild45/ethanl/swfeature_int/pkt'

So far I came up with this:

errorformat=%f:%l:\ %m,%Dgmake[%\\d%\\*]:\ Entering\ directory\ `%f',%Xgmake[%\\d%\\*]:\ Leaving\ directory%s

It opens the file and puts me to the first error, but I have to type :cn four times to get to the second error. I've tried to setup multiline errors, but so far my error string doesn't work:

errorformat=%-Z%f:\ %s,%C%f:%l:\ %m,%A%f:\ %m,%Dgmake[%\\d%\\*]:\ Entering\ directory\ `%f',%Xgmake[%\\d%\\*]:\ Leaving\ directory%s

Do you have a better idea?


Solution

  • It may help to open the quickfix window

    :copen
    

    You can then visually navigate through your error list and type <enter> on the error you are interested in to jump directly to the line in question.

    Also see

    :help quickfix