2016年3月29日 星期二

vim套件 - cscope

1. 安裝Cscope
$ sudo apt-get install cscope
2. 將cscope_maps.vim內容加入.vimrc
http://cscope.sourceforge.net/cscope_maps.vim

3. 產生ctags關聯檔
$ find . -name *."[ch]" > cscope.files
$ ctags -L cscope.files
$ cscope -Rbki cscope.files

-R            Recurse directories for files.
-b            Build the cross-reference only.
-k            Kernel Mode - don't use /usr/include for #include files.
-i namefile   Browse through files listed in namefile, instead of cscope.files
4. HOW TO USE WITH VI
一個範例: cs find s 

    "   '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
5. 參考來源
http://cscope.sourceforge.net/

沒有留言:

張貼留言