顯示具有 plugin 標籤的文章。 顯示所有文章
顯示具有 plugin 標籤的文章。 顯示所有文章

2013年1月14日 星期一

顯示 java class list

開啟 java source 時,在左邊列出這個 java file 所有的 class, field, method.
plugin 的名子叫 JavaBrowser.

http://www.vim.org/scripts/script.php?script_id=588

Instal:

Download最新版,unzip 解開,找到 vimfile/plugin 下的 JavaBrowser.vim。
copy 到 ~/.vim/plugin

要注意系統要有 ctags。

測試:

開啟一個 java file,在command 輸入: :JavaBrowser

就可以看到左邊被開了一排,顯示 java file 裡所有的 field, method, class..

用 ctrl-w, w 移動到左邊,在對應的宣告名稱按下 enter,
右邊的 source 就會移動到 source line。

同樣的,在 source code 中移動,稍微停頓 1,2 sec,
左邊的 list 會update,停在 source code 的 function name 中。

要關掉的話,一樣下 JavaBrowser 命令,那是一個 toggle 命令

2012年1月10日 星期二

ctags

跟 cscope 有點類似。
  1. 先產生 database : ctags -R
  2. 開檔,編輯
  3. 使用 ctag command
好像可以跟 cscope 一起用 (command 不衝突)
command:

到 定義: Ctrl-]
回去,跟cscope 一樣: Ctrl-T
在函数中移动光标的快捷键: [{ 转到上一个位于第一列的"{" }] 转到下一个位于第一列的"{" { 转到上一个空行 } 转到下一个空行 gd 转到当前光标所指的局部变量的定义 * 转到当前光标所指的单词下一次出现的地方 # 转到当前光标所指的单词上一次出现的地方



ref : http://blog.csdn.net/wangyunqian6/article/details/6608238

2011年10月6日 星期四

cscope : browsing codes with cscope

cscope 要先建 database,
加上 cscope for vim 的 key mapping 才能動作。

  1. 建立要cscope 處理的檔案列表
  2. 要 cscope 根據列表產生 database

cscope 會依照 cscope..files 的內容 (檔案量列表),
parsing context 產生data base。
如果是 linux kernel,
可以用 find command 找出要的 source file。

以下就是以 ARM 為例子的 shell script: #!/bin/sh find . \ -path "arch/arm/*" -prune \ -o -path "include/asm-*" \ ! -path "include/asm-i386*" -prune \ -o -path "tmp*" -prune \ -o -path "Documentation*" -prune \ -o -path "scripts*" -prune \ -o -path "drivers*" -prune \ -o -name "*.[chxsS]" -print > cscope.files 在 kernel source folder 執行完 script ,會在目錄下產生 cscope.files。


接著產生 database..

在目錄下作 cscope -b -q -k
  1. -b : 產生 database 就好,不用 launch gui
  2. -q : 產生 reverse index,方便 search
  3. -k : kernel mode , 不要對 ./usr/include 作 index


做完以上動作,cscope 的 資料就 OK 了。

下載 cscope for vim 的 keymapping 檔。
cscope_maps.vim

download 到 .vim/plugin/ 下
--- 沒有這個目錄就自己 create 一個。


之後就可以像平常一樣開啟任何一個 source file。
然後.. 在任何變數 , function 按 Ctrl \ + g 到 定義的地方。

Ctrl \ + d 列出這個 function 所有呼叫到的 function,讓你挑選。

Ctrl \ + c 到 call 這個 function 的 code 去。


要回到上一個地方用: Ctrl t
可以用 :cs help列出command.... find : Query for a pattern (Usage: find c|d|e|f|g|i|s|t name) c: Find functions calling this function d: Find functions called by this function e: Find this egrep pattern f: Find this file g: Find this definition i: Find files #including this file s: Find this C symbol t: Find assignments to
ref:
  1. http://cscope.sourceforge.net/large_projects.html
  2. http://http://forteallan.pixnet.net/blog/post/24394720-cscope-%5B%E7%80%8F%E8%A6%BD%E7%A8%8B%E5%BC%8F%E7%A2%BC%E5%B7%A5%E5%85%B7-built-with-vim%5D"
  3. http://softsmith.blogspot.com/2009/01/vim-cscope-trace.html
  4. http://adrianhuang.blogspot.com/2007/09/trace-code-gvimctagscscope.html