歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> 使用vim來代替source insight

使用vim來代替source insight

日期:2017/2/28 17:25:57   编辑:Linux教程

vim + ctags + taglist + cscope + cppcomplete + global 使用初探

相關的擴展的安裝

代碼:
apt-get install exuberant-ctags cscope global
cppcomplete 和 taglist 要到www.vim.org的擴展列表中下載。

taglist 的下載地址:
http://www.vim.org/scripts/script.php?script_id=273
cppcomplete 的下載地址:
http://www.vim.org/scripts/script.php?script_id=527

然後在 建立目錄

代碼:
$HOME/.vim/plugin

將下載的cppcomplete.vim 和 taglist.vim拷貝到$HOME/.vim/plugin中。
安裝了global後,最新4.8.6 以上版本有帶vim的擴展,將它也拷貝到 $HOME/.vim/plugin

debian sid 版本global安裝後擴展文件在

代碼:
/usr/share/doc/global/examples/gtags.vim.gz
需要拷貝到$HOME/.vim/plugin後解壓,解壓方法:

代碼:
gzip -d gtags.vim.gz


3、使用這些工具
1)准備工作,先修改一下$HOME/.vimrc文件

為了更好的使用cscope請添加如下內容,這樣Ctrl-]的跳轉將由cscope的tags進行分析。

代碼:
if has("cscope")set csprg=/usr/bin/cscopeset csto=0set cstset nocsverb" add any database in current directoryif filereadable("cscope.out")cs add cscope.out" else add database pointed to by environmentelseif $CSCOPE_DB != ""cs add $CSCOPE_DBendifset csverbset cscopetagset cscopequickfix=s-,g-,c-,d-,t-,e-,f-,i-endif

2)使用cscope
cscope的tag生成最簡單的方法是:
在你的開發工程的最上層目錄執行cscope-indexer,它會遍歷下面的所有目錄,生成兩個文件,一個是cscope.files,這個文件記錄需要生成tags的文件名,可以手工修改,另一個是cscope格式的tags文件cscope.out。

完成後,你在生成了cscope.out的目錄打開工程的任意文件,就可以使用Ctrl-]跳轉查找類型定義了。

代碼:
cs f s xxxx 查找xxxx出現的地方,它能詳細列出哪些文件的哪行的哪個函數引用,以及該行的內容,比較不錯。 :)

它的所有命令的使用請參考:

代碼:
help cscope

Copyright © Linux教程網 All Rights Reserved