易春木

Feed Rss

程式碼可以用tag方式: 將vim當作source insight 來使用

12.20.2011, 記事本, by , 296 人次 .

Trace source at vim
幾個步驟大綱:

  • Introduce
  • Install
  • Setup
  • Tag Your Codebase
  • Text Editor
  • 進階版


[Introduce ]

•Source Insight
–Good IDE
–Good at Windows platform
–Bad Overload files
•But what if you ...
–Non-Windows platform (BSD, Linux, …)
–Command line interface (CLI)
–Dislike brute force search : find / grep

[Tools ]

•vim
•ctags
•taglist

[Install ]

•apt-get install vim
•apt-get install exuberant-ctags
•Download taglist
–Steps:
•下載後解壓縮該檔案
# unzip taglist_45.zip
•將plugin及doc複製到家目錄的“.vim”目錄裏(~ /.vim/) ,如果不存在就建一個新的".vim"

[setup ]

•Modify /etc/vim/vimrc
map <f7> :Tlist<CR>

[Tag Your Codebase ]

ctags -R -h ".h.c.cpp.java"

[Text Editor ]

•Keys:
–F7
•Enable / Disable ctags
–Ctrl + w + w
•Switch window
–Left side (Tag List):
•按Enter就會自動跳到相對應的函式或定義
–Right side:
•Ctrl + ] : 跳到游標所指function的implement 位置
•Ctrl + t : 返回到剛剛的位置

[進階版 ]

•apt-get install cscope
•Download
–Unzip and put these plugin files to
•~ /.vim/plugin

•Modify /etc/vim/vimrc
" Open and close all the three plugins on the same time
‚nmap <F8> :TrinityToggleAll<CR>
" Open and close the srcexpl.vim separately
‚nmap <F9> :TrinityToggleSourceExplorer<CR>
ƒ
ƒ" Open and close the taglist.vim separately
„nmap <F10> :TrinityToggleTagList<CR>
…
…" Open and close the NERD_tree.vim separately
†nmap <F11> :TrinityToggleNERDTree<CR>
‡
‡set mouse=nv

[參考]:

•Ctags:
•Taglist:
•Ubuntu安裝Vim Plugin ctags及taglist
•Vim + Trinity + Source Explorer + Tag List + NERD_tree + ctags
•take it easy:vim+trinity+tabbar

閱讀這篇文章的讀者也會看:

發表迴響

您的電子郵件位址並不會被公開。 必要欄位標記為 *

*

您可以使用這些 HTML 標籤與屬性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>