vim外掛程式cscope工具的編譯、安裝與使用

來源:互聯網
上載者:User

標籤:

vim外掛程式cscope工具的編譯、安裝與使用

1. 下載:http://download.chinaunix.net/download.php?id=3536&ResourceID=1900
2. 編譯
# ./configure 
#make
make 失敗了:
[email protected]:~/.vim/cscope-15.5# make
make  all-recursive
make[1]: Entering directory ‘/root/.vim/cscope-15.5‘
Making all in doc
make[2]: Entering directory ‘/root/.vim/cscope-15.5/doc‘
make[2]: Nothing to be done for ‘all‘.
make[2]: Leaving directory ‘/root/.vim/cscope-15.5/doc‘
Making all in src
make[2]: Entering directory ‘/root/.vim/cscope-15.5/src‘
/bin/bash ../ylwrap `test -f ‘fscanner.l‘ || echo ‘./‘`fscanner.l .c fscanner.c -- :  
Makefile:310: recipe for target ‘fscanner.c‘ failed
make[2]: *** [fscanner.c] Error 1
make[2]: Leaving directory ‘/root/.vim/cscope-15.5/src‘
Makefile:199: recipe for target ‘all-recursive‘ failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory ‘/root/.vim/cscope-15.5‘
Makefile:154: recipe for target ‘all‘ failed
make: *** [all] Error 2


3.cscope-15.5是03年的,非常老,換個新的版本cscope-15.8a.tar.gz
執行:
./configure
make
make install
編譯通過,安裝成功
3. 使用
進入核心目錄:
cd /study/linux-git/linux-3.18.3
執行
cscope -Rbq 
set tags=/study/linux-git/linux-3.18.3
:cs add cscope.out
:cs find c writel
這樣,就可以看到是哪裡有writel的定義了


如下內容參考自:vi/vim使用進階: 程式員的利器 – cscope
(http://blog.csdn.net/xiangpingli/article/details/44007021)
這個命令會產生三個檔案:cscope.out, cscope.in.out, cscope.po.out。其中cscope.out是基本的符號索引,後兩個檔案是使用”-q“選項產生的,可以加快cscope的索引速度。
在vim中使用cscope非常簡單,首先調用”cscope add“命令添加一個cscope資料庫,然後就可以調用”cscope find“命令進行尋找了。vim支援8種cscope的查詢功能,如下:


s: 尋找C語言符號,即尋找函數名、宏、枚舉值等出現的地方
g: 尋找函數、宏、枚舉等定義的位置,類似ctags所提供的功能
d: 尋找本函數調用的函數
c: 尋找調用本函數的函數
t: 尋找指定的字串
e: 尋找egrep模式,相當於egrep功能,但尋找速度快多了
f: 尋找並開啟檔案,類似vim的find功能
i: 尋找包含本檔案的檔案
例如,我們想在source的原始碼中尋找調用do_cscope()函數的函數,我們可以輸入:”:cs find c do_cscope“,
斷行符號後發現沒有找到匹配的功能,可能並沒有函數調用do_cscope()。我們再輸入”:cs find s do_cscope“,尋找這個C符號出現的位置,現在vim列出了這個符號出現的所有位置。
vimrc中關於cscope介面的設定,使用時候加在.vimrc末尾:


"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" cscope setting
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if has("cscope")
  set csprg=/usr/local/bin/cscope
  set csto=1
  set cst
  set nocsverb
  " add any database in current directory
  if filereadable("cscope.out")
      cs add cscope.out
  endif
  set csverb
endif




vim外掛程式cscope工具的編譯、安裝與使用

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.