Thursday 16 January 2014

the vim cscope easy tutorial

The following steps to help you to set up cscope easily.

1. install cscope:
user@ubuntu-64bit:~$ sudo apt-get install cscope

2. Download the cscope_maps.vim file, put it to $HOME/.vim/plugin directory:
user@ubuntu-64bit:~$ mv Desktop/cscope_maps.vim .vim/plugin/  

3. Try setting the $CSCOPE_DB environment variable to point to a Cscope database you create:
    find /my/project/dir -name '*.c' -o -name '*.h' > /foo/cscope.files
   Then run Cscope in the same directory as the cscope.files file (or use 'cscope -i /foo/cscope.files'), then set and export the $CSCOPE_DB variable, pointing it to            the cscope.out file that results):
    cd /foo
    cscope -b 
    CSCOPE_DB=/foo/cscope.out; export CSCOPE_DB    


add the commands:
    " The following maps all invoke one of the following cscope search types:
    "
    " 's' symbol: find all references to the token under cursor
    " 'g' global: find global definition(s) of the token under cursor
    " 'c' calls: find all calls to the function name under cursor
    " 't' text: find all instances of the text under cursor
    " 'e' egrep: egrep search for the word under cursor
    " 'f' file: open the filename under cursor
    " 'i' includes: find files that include the filename under cursor
    " 'd' called: find functions that function under cursor calls


    " To do the first type of search, hit 'CTRL-\', followed by one of the
    " cscope search types above (s,g,c,t,e,f,i,d). 

No comments:

Post a Comment