在 vim 中使用 cscope 仅在给定文件中查找符号
我想转到给定文件中的一个符号(例如 main)。 是否可以使用 cscope 将搜索范围限制为给定文件?
:cs find s main
如果没有这个,当我查找像 main 这样的符号时,我会得到一百多个结果在我的项目中,我必须识别并输入数字(如 90)才能导航到该符号。
对于像“main”这样可能在文件中出现几次的常见单词,使用 vim 搜索转到感兴趣的文件并搜索符号的选项很麻烦。
I want to go to a symbol (say main) in a given file. Is it possible to restrict the scope of search to given files with cscope?
:cs find s main
Without this, when I look for a symbol like main, I get hundred plus results in my project and I have to identify and type the number like 90 to navigate to the symbol.
The option of going to the file of interest and searching for the symbol using vim search is cumbersome for common words like "main" which may be present a handful of times in the file.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不可以。Cscope 本身不允许您这样做,因此 Vim 的 cscope 集成也不允许您这样做。
如果您想摆脱这个特定的困境,您可能需要考虑一些事情......
如果您使用的工具不能满足您的要求,那么它是正确的工具吗?
到底为什么要跳转到该特定文件中的特定
main()
?接下来您要做什么?在我看来,跳转到
main()
本身似乎没有任何目的,因为它通常是一个入口点。因此,“跳转到foo.c
中的main()
”并不比“跳转到foo.c
”好多少。这似乎只是另一个中间步骤。还有另一种方法可以做到这一点吗?
我应该放弃该工作流程,转而采用更好的工作流程吗?
如果您知道
foo.c
中有一个main()
,那么 cscope 有一些更简单的替代方案,例如:或:
No. Cscope itself doesn't let you do that so Vim's cscope integration doesn't either.
If you want to get out of this specific hole, you may have to ponder a few things…
Is The tool you are using the right tool if it doesn't do what you want?
Why, exactly, do you want to jump to that specific
main()
in that specific file? What do you do next?The way I see it, jumping to a
main()
doesn't seem to serve any purpose in and of itself as it is usually an entry point. As such, "jump tomain()
infoo.c
" is not much better than "jump tofoo.c
". It seems to be just another intermediary step.Is there another way to do exactly that?
Should I abandon that workflow in favour of a better one?
If you know there is a
main()
infoo.c
, there are a few simpler alternatives to cscope, like:or: