3

I am trying to use cscope with vim and I find things a little confusing.

Let’s say I have a project in /home/user/projects/project_foo/. If I go through cscope directly it all works fine (I can find symbols). If I go through vim I get no cscope connections error. So I don’t understand how it works.

As far as I understand you have to build a database for your project, but when I run cscope [-R] [-b] in project’s directory no file is created in this directory. So where is the database created? Is there a separate database for each project or a global database?

Do I have to rebuild the database each time I make a change to the project symbols (e.g. add a function)?

How do I make vim (loaded from the project’s directory) to use the database for that project. If there is a global database can I make vim search only within the current project?

I found some scattered information about this things but it is all very confusing for a first time user. If you could clarify these things it would make it more clear and I would be able to figure out the rest.

bolov
  • 72,283
  • 15
  • 145
  • 224
  • I know I technically asked more than one question but it all boils down to the the question in the title and I don’t think 3 separate questions on this site would be justified in this case. – bolov Aug 27 '14 at 07:25
  • 1
    you may want to start from :h cscope-howtouse and :h cscope-suggestions – tristan Aug 27 '14 at 07:32
  • @tristan thank you. Just what I needed. Also, I didn’t see the `cscope.out` file created. Blind me. – bolov Aug 27 '14 at 07:36
  • @tristan I feel so silly now I almost want to down-vote my question :)) – bolov Aug 27 '14 at 07:42

2 Answers2

5

Thanks to tristan:

:h cscope-howtouse
:h cscope-suggestions 

cscope -b creates the database cscope.out.
:cs add cscope.out adds the database.

Community
  • 1
  • 1
bolov
  • 72,283
  • 15
  • 145
  • 224
1

Do I have to rebuild the database each time I make a change to the project symbols (e.g. add a function)?

If you want to be able to find that particular function, yes. You can still do without rebuilding the database, but if you will add lines of code (for example), cscope will point you to the original location of a symbol it had in the file when the database was created.

How do I make vim (loaded from the project’s directory) to use the database for that project. If there is a global database can I make vim search only within the current project?

You can do do that by changing the vimrc script. The Autoloading cscope database tutorial is a good example for things that you can configure.

Nikopol
  • 1,091
  • 1
  • 13
  • 24