开发者

How to put cscope output in Vim quickfix window?

开发者 https://www.devze.com 2023-03-20 04:23 出处:网络
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):

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 linen开发者_C百科umber 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?


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
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号