建立 vim 類似 source insight的工作環境

需要套件

Vim + Trinity + Source Explorer + Tag List + NERD_tree + ctags

 參數快捷健設定

修改 vimrc檔 (/etc/vim/vimrc)並加入以下幾個設定:


" Open and close all the three plugins on the same time
nnoremap <silent> <F7> :TrinityToggleAll<CR>
" Open and close the srcexpl.vim separately
nnoremap <silent> <F9> :TrinityToggleSourceExplorer<CR>
" Open and close the taglist.vim separately
nnoremap <silent> <F10> :TrinityToggleTagList<CR>
" Open and close the NERD_tree.vim separately
nnoremap <silent> <F12> :TrinityToggleNERDTree<CR>
" Open NERDTree
nnoremap <silent> <F5> :NERDTree<CR>


set mouse=nv

安裝各個套件

cscope

apt-get install exuberant-ctags cscope
功能:使之可以尋找關鍵字

Trinity

Link : http://www.vim.org/scripts/script.php?script_id=2347
功能:用來管理 Source Explorer, Tag List, NERD_tree的 plugin

Source Explorer 

Link :  http://www.vim.org/scripts/script.php?script_id=2179
功能:用來自動顯示定義
說明:最底部的視窗

Tag List

Link :  http://www.vim.org/scripts/script.php?script_id=273
功能:顯示標籤資訊
說明:左邊的視窗

NERD_tree

Link :  http://www.vim.org/scripts/script.php?script_id=1658
功能:顯示檔案列表
說明:右邊的視窗

ctags

apt-get install exuberant-ctags

操作方式

1. 讓程式有搜尋功能
a. 產生 cscope.files
-> find -name '*.c' -o -name '*.cpp' -o -name '*.java' -o -name '*.h' > cscope.files
b. 產生cscope.out, cscope.in.out, cscope.po.out
->  cscope -Rbkq cscope.files

2. 建立程式碼的索引檔
ctags -R --exclude=.svn

3. 執行啟動cscope
cscope
結束時按下 ctrl+d 離開
-> 解決無法執行cs指令的問題

3. 利用vim 開啟檔案, 按下F7 即可開啟.

4. 建立連接
:cscope add /path/to/cscope.out /path/to/src/code
-> 解決cs f c [方法名稱]時, file not exist的問題

留言

這個網誌中的熱門文章

camera 知識 - 3A

董事會簡報範本