質問

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?

役に立ちましたか?

解決 2

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

他のヒント

Well, certainly multiline error format is a pain in the ass, so you need a method to refine your errorformat quickly.

  1. redirect your compilation output to a file or a vim buffer (so you can play with it if neccesary)

    $ make &> <your-error-file>
    
  2. goto vim, open quickfix window

    :copen
    
  3. start your refine loop

    :set errorformat=<whatever>
    :caddf <your-error-file>
    :cex []
    :set errorformat=<whatever>
    :caddf <your-error-file>
    ...
    

explaining:

  1. set an error format
  2. read your error file. You can replace that with

    :read <your-error-file>
    :caddbuffer
    

That ease to change your input, to detect different errors

If results are not the expected:

  1. clean quickfix window

    :cex []
    

That command load an empty list to quickfix window

For your question

:set errorformat=%f:%l:\ %trror:\ %m,%Dgmake[%*\\d]:\ Entering\ directory\ `%f',%Xgmake[%*\\d]:\ Leaving\ directory\ `%f',%-G%.%#

should be enough

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top