這以 GNU GLOBAL 6.5.6 為示範
1:
install GNU GLOBAL
https://www.gnu.org/software/global/download.html
sudo ./configure;
若有以下 error,請看更下方的 Q5 說明。
configure: checking "location of ncurses.h file"... configure: error: curses library is required but not found. If you are not going to use gtags-cscope, please try ./configure --disable-gtagscscope
sudo make;
sudo make install
----------------------------------------------------------------------------------------------------
Q5. What is the message? What should I do?
‘configure: error: curses library is required but not found."
A5. gtags-cscope(1) requires curses library. There are two choices of yours.
If you use gtags-cscope(1)
Please install curses library. You can get it here:
http://www.gnu.org/software/ncurses/
else
You can install GLOBAL without gtags-cscope(1) like follows:
$ ./configure --disable-gtagscscope
$ make
因為這裡要使用 gtags-cscope,
所以要 install curses library. 參考下方
-------------------------------------------------------------------------------------------------------
2:
install curses library
http://www.gnu.org/software/ncurses/
sudo ./configure; sudo make; sudo make install;
3 :
install vundle
https://github.com/VundleVim/Vundle.vim
sudo apt-get install git curl
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
請看 https://github.com/VundleVim/Vundle.vim 的 Quick Start 的 第3步驟 Configure Plugins:
4 :
以下要依照 user 當時所安裝的 gnu global 版本,plugin 對應版本的 gtags.vim、gtags-cscope.vim,
可以下載 gnu global source code,裡面就有對應版本的 gtags.vim、gtags-cscope.vim
或是在網路上搜尋對應版本的 gtags.vim,gtags-cscope.vim 並使用以下的 Vundle plugin 方式
Plugin ‘bbchung/gtags.vim‘ Plugin ‘multilobyte/gtags-cscope‘
5:
在您要 tag 的 source code 的資料夾下,
執行
gtags
6:
假如您在 source code 找一個定義,
:cs find g the_definition_you_want_find
若出現以下訊息
E567: no cscope connections
需在 ~/.vimrc 加入以下
let g:GtagsCscope_Auto_Load = 1
若需要使用 cscope 的快捷鍵, ===〉 注意,VirtualBox 4.3.36 無法使用組合鍵,如 ctrl 加上 \ 再加上 s
快捷鍵在 gtags-cscope.vim 有說明,
需在 ~/.vimrc 加入以下 code 。
let g:GtagsCscope_Auto_Map = 1
cscope command
54 " explanation command 55 " ---------------------------------------------------------- 56 " Find symbol :cs find 0 or s 57 " Find definition :cs find 1 or g 58 " Find functions called by this function (not implemented) 59 " Find reference :cs find 3 or c 60 " Find text string :cs find 4 or t 61 " Find egrep pattern :cs find 6 or e 62 " Find path :cs find 7 or f ===> 跳至 include 的 file。如:#include "t.h",跳至 t.h 63 " Find include file :cs find 8 or i ===> 找尋有那些 source code 有 include 這個 文件。 如: a.c b.c 都有 include "c.h"
快捷鍵
ctrl + \ + s | g | c | t | e | f | i
232 " normal command 233 :nmap <C-\>s :cs find s <C-R>=expand("<cword>")<CR><CR> 234 :nmap <C-\>g :cs find g <C-R>=expand("<cword>")<CR><CR> 235 :nmap <C-\>c :cs find c <C-R>=expand("<cword>")<CR><CR> 236 :nmap <C-\>t :cs find t <C-R>=expand("<cword>")<CR><CR> 237 :nmap <C-\>e :cs find e <C-R>=expand("<cword>")<CR><CR> 238 :nmap <C-\>f :cs find f <C-R>=expand("<cfile>")<CR><CR> 239 :nmap <C-\>i :cs find i <C-R>=expand("<cfile>")<CR><CR>