vim 无法连接到 cscope 数据库
我安装了 opensuse 11.4。 Vim 是版本 7。现在我通常用它来浏览 linux 内核源代码。所以我在我的主文件夹中的一个目录中生成了 cscope 数据库,即 /home/aijazbaig1/cscope_DB/ ,我得到了 3 个文件,即:除了 cscope.files 文件之外,cscope.out、cscope.po.out 和 cscope.in.out 还包含我要搜索的所有相关文件的列表。
另外,我已将以下内容添加到我的 .bashrc 中:
CSCOPE_DB=/home/aijazbaig1/cscope_DB/cscope.out
export CSCOPE_DB
但是当我在 vim 中执行 :cscope show
时,它说没有连接。谁能告诉我出了什么问题。
渴望收到你的来信,
I have opensuse 11.4 installed. Vim is version 7. Now I normally use it to browse the linux kernel source. So I generated the cscope database inside a directory within my home folder i.e. /home/aijazbaig1/cscope_DB/ and I got 3 files viz. cscope.out, cscope.po.out and cscope.in.out besides the cscope.files file which contains a list of all the relevant files which I want to search.
Additionally I have added the following to my .bashrc:
CSCOPE_DB=/home/aijazbaig1/cscope_DB/cscope.out
export CSCOPE_DB
But when I do a :cscope show
from within vim it says there are no connections. Can anyone please let me know what is going wrong.
Keen to hear from you,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
上面的评论中提到了这一点,但我想确保它保留在答案中。
我遇到的问题是 vim 不知道在哪里查找 cscope 数据库。当我添加
到我的
.vimrc
时。一切都很好。This is mentioned in the comments above, but I want to make sure it's preserved in an answer.
The issue that came up for me was that vim didn't know where to look for the cscope database. When I added
to my
.vimrc
. Everything came out fine.我想既然我已经访问过,我会尝试做出回应。
使用 ctrl-space s 搜索(或任何与此相关的搜索)时出现此错误:
我终于在 http://cscope.sourceforge.net/cscope_vim_tutorial.html 找到了完整的解决方案,步骤 11。
想法是创建要包含在 cscope 视图中的源文件列表,在同一位置生成 cscope.out,并更新导出路径相应地:
cscope -R -b
(这可能需要一段时间,具体取决于源的大小)export CSCOPE_DB=/foo/cscope.out
code> (如果您不想每次登录终端时都重复此操作,请将其放入您的 .bashrc/.zshrc/other-starting-script 中)I figure since I've made the visit, I would try responding.
I was getting this error when searching using ctrl-space s (or any search for that matter):
I finally found the full solution at http://cscope.sourceforge.net/cscope_vim_tutorial.html, Step 11.
The idea is that you create a list of source files to be included in the view of cscope, generate the cscope.out in the same location, and update the export path accordingly:
find /my/project/dir -name '*.c' -o -name '*.h' > /foo/cscope.files
cscope -R -b
(this may take a while depending on the size of your source)export CSCOPE_DB=/foo/cscope.out
(put this in your .bashrc/.zshrc/other-starting-script if you don't want to repeat this every time you log into the terminal)您需要添加一个“cscope 连接”,就像在 vim 中一样:
有关更多示例,请参阅
:help cs
。You need to add a "cscope connection", like this in vim:
See
:help cs
for more examples.以下是我如何使用 cscope 探索 Linux 内核源代码:
我使用 vim 作为编辑器。
cscope
,同时在搜索源文件期间递归地遍历子目录:cscope -R
第一次运行时,它将在当前目录中生成名为:
cscope.out
的数据库文件。任何后续运行都将使用已生成的数据库。:tag
和CTRL-]
命令先搜索 cscope,然后再搜索 ctags 的标签::set cscopetag
:cs add cscope.out
现在您可以使用
CTRL-]
和CTRL-t
,就像在ctags 来导航! :)Here's how I explore linux kernel source using cscope:
I use vim as my editor.
cscope
in interactive mode while recursively going through subdirectories during search for source files:cscope -R
When run for the first time, it will generate the database file with the name:
cscope.out
inside the current directory. Any subsequent runs will use the already generated database.:tag
andCTRL-]
commands search through cscope first and then ctags' tags::set cscopetag
:cs add cscope.out
Now you can use
CTRL-]
andCTRL-t
as you would do in ctags to navigate around! :)我的电脑上也有同样的问题。现在,要解决这个问题:
在终端上执行:
which is cscope
打开 .vimrc 文件编辑:
set csprg=/usr/bin/cscope
I have the same issue on my PC. For now, to solve the issue:
On terminal execute:
which is cscope
Open .vimrc file to edit:
set csprg=/usr/bin/cscope
我在 ubuntu 18.04 上遇到了类似的问题,没有 cscope 连接,然后我发现我的 .vimrc 文件没有加载 CSCOPE_DB 变量。环顾四周,发现了一个解决方案。
您可以直接将其复制到您的 .vimrc 文件中。
部分代码从您的目录加载 cscope 文件。按键绑定只是一个不错的奖励。
希望这有帮助。
I ran into a similar problem with no cscope connections on ubuntu 18.04, then I discovered my .vimrc file does not load the CSCOPE_DB variable. Looked a little around and found a solution.
You can just copy this directly in to your .vimrc file.
Part of the code loads your cscope file from your directory. The keybinds are just a nice bonus.
Hope this helps.