vim 无法连接到 cscope 数据库

发布于 2024-11-16 22:08:44 字数 430 浏览 3 评论 0原文

我安装了 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

余罪 2024-11-23 22:08:44

上面的评论中提到了这一点,但我想确保它保留在答案中。

我遇到的问题是 vim 不知道在哪里查找 cscope 数据库。当我添加

cs add $CSCOPE_DB

到我的 .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

cs add $CSCOPE_DB

to my .vimrc. Everything came out fine.

蓝礼 2024-11-23 22:08:44

我想既然我已经访问过,我会尝试做出回应。

使用 ctrl-space s 搜索(或任何与此相关的搜索)时出现此错误:

E567:没有 cscope 连接

我终于在 http://cscope.sourceforge.net/cscope_vim_tutorial.html 找到了完整的解决方案,步骤 11。

想法是创建要包含在 cscope 视图中的源文件列表,在同一位置生成 cscope.out,并更新导出路径相应地:

  • find /my/project/dir -name '*.c' -o -name '*.h' > /foo/cscope.files
  • 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):

E567: no cscope connections

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)
带刺的爱情 2024-11-23 22:08:44

您需要添加一个“cscope 连接”,就像在 vim 中一样:

:cscope add $PATH_TO_CSCOPE.out 

有关更多示例,请参阅 :help cs

You need to add a "cscope connection", like this in vim:

:cscope add $PATH_TO_CSCOPE.out 

See :help cs for more examples.

北城半夏 2024-11-23 22:08:44

以下是我如何使用 cscope 探索 Linux 内核源代码:

我使用 vim 作为编辑器。

  1. 站在内核源代码根目录中,以交互模式运行 cscope,同时在搜索源文件期间递归地遍历子目录:

cscope -R

第一次运行时,它将在当前目录中生成名为:cscope.out 的数据库文件。任何后续运行都将使用已生成的数据库。

  1. 搜索任何内容或任何文件并将其打开。
  2. 在 vim 中设置 cscope 标签,使 :tagCTRL-] 命令先搜索 cscope,然后再搜索 ctags 的标签:

:set cscopetag

  1. 设置当前 VIM 会话中的 cscope 数据库:

:cs add cscope.out

现在您可以使用 CTRL-]CTRL-t ,就像在ctags 来导航! :)

Here's how I explore linux kernel source using cscope:

I use vim as my editor.

  1. While standing inside the kernel source root directory, run 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.

  1. Search for anything or any file and open it.
  2. Set cscope tags in vim to make the :tag and CTRL-] commands search through cscope first and then ctags' tags:

:set cscopetag

  1. Set cscope database inside current VIM session:

:cs add cscope.out

Now you can use CTRL-] and CTRL-t as you would do in ctags to navigate around! :)

转身以后 2024-11-23 22:08:44

我的电脑上也有同样的问题。现在,要解决这个问题:

  1. 在终端上执行:which is cscope

  2. 打开 .vimrc 文件编辑: set csprg=/usr/bin/cscope

I have the same issue on my PC. For now, to solve the issue:

  1. On terminal execute: which is cscope

  2. Open .vimrc file to edit: set csprg=/usr/bin/cscope

万劫不复 2024-11-23 22:08:44

我在 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文