How to put cscope output in Vim quickfix window?

安稳与你 提交于 2019-12-08 17:38:09

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!