It took me some time, but I started to obtain some experience with cscope and ctags.
I will try to keep this post updated from time to time, since I think it might help me (and maybe others) to have more efficient code navigating.
Currently I want to share my basic setup.
-
The information is gathered from this cscope tutorial and this ctags tutorial
-
After the installation of those components, in the source directory of the project I do
ctags -R *
cscope -R -b
- Now, I act according to this post and set the correspond environment variable:
export CSCOPE_DB=/foo/cscope.out
and I also add a reference to it in vimrc cs add $CSCOPE_DB
-
I also
:set cscopetag
inside vim to make the cscope use the ctags indexes -
Finally, I locate myself in the source folder (This is important since all tags are relative to this folder) and I navigate from there. (i.e after
cd
the source folder I justvim
and keep on from there)
This should be enough to make the indexes work. Some basic keys are
-
Ctrl-]
to jump to a tag -
Ctrl-t
to take a backward step -
:ts
for searching a tag. (i.e. yank a tag withyw
and then:ts Ctrl+R+"
to see it’s refrences