How to set up cscope for vim?

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 cscope

right through everything works fine (I can find symbols). If I go through vim

, I get an error no cscope connections

. So I don't understand how it works.

As I understand it, you should create a database for your project, but when I run cscope [-R] [-b]

in the projects directory no file is created in that directory. So where is the database created? Is there a separate database for each project or global database?

Do I need to rebuild the database every time I make changes to the symbols of the project (for example add a function)?

How do I vim

(loaded from the projects directory) to use the database for this project. If there is a global database, can I vim

only do a search in the current project?

I found some scattered information about this, but it is all very confusing for the user the first time around. If you could clarify this, it would make it clearer and I could figure out the rest.

+3


source to share


2 answers


Thanks to tristan :

:h cscope-howtouse
:h cscope-suggestions 

      



cscope -b

creates a database cscope.out

.
:cs add cscope.out

adds a database.

+2


source


Do I need to rebuild the database every time I make changes to the symbols of the project (for example add a function)?

If you want to search for that specific feature, yes. You can still do without restoring the database, but if you add lines of code (for example), cscope will point you to the original location of the symbol it had in the file when the database was created.



How do I make vim (loaded from the projects directory) to use the database for this project. If there is a global database, can I do vim search on the current project only?

You can do this by modifying the vimrc script. The cscope database autoloading is a good example of what you can customize.

+1


source