问题
I want to redirect output from cscope to Vim quickfix window. The glue part is easy enough, but I currently stuck at errorformat. Here's an example from cscope output (cscope -L -1 bar):
Format: "filename scope linenumber sourceline"
Example: "abc.cpp foo 25 bar()"
This means inside foo(), at line 25 in abc.cpp there is a call to bar().
efm = %f\ %*[^\ ]\ %l\ %m
works but the scope information is lost. For example:
Input: "abc.cpp foo 25 bar()" becomes
Output: "abc.cpp |25| bar()"
What I want is to include the scope in quickfix window, like this:
Input: "abc.cpp foo 25 bar()" becomes
Output: "abc.cpp |25| bar() inside foo()"
Is it possible to do this with errorformat only, or do I need to write a script to manipulate the output before feeding it to Vim?
回答1:
Instead of messing about with errorformat
, just set cscopequickfix
and use the normal :cscope
commands. eg. (from vim help)
:set cscopequickfix=s-,c-,d-,i-,t-,e-
Edit
You could also use a filter like the following to reorder the fields
sed -e 's/^\([^ ]\+\) \([^ ]\+\) \([^ ]\+\) \(.*\)$/\1 \3 \4 inside \2/'
set it to filter your message, then use the efm
errorformat=%f\ %l\ %m
来源:https://stackoverflow.com/questions/6677756/how-to-put-cscope-output-in-vim-quickfix-window