vim使ç¨è¿é¶
vim使ç¨è¿é¶
vim使ç¨è¿é¶
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
程 序 员 的 利 器 - cscope<br />
再 输 入 ":cs find s do_cscope", 查 找 这 个 C 符 号 出 现 的 位 置 , 现 在 vim 列 出 了 这 个 符 号 出 现 的 所<br />
有 位 置 。<br />
我 们 还 可 以 进 行 字 符 串 查 找 , 它 会 双 引 号 或 单 引 号 括 起 来 的 内 容 中 查 找 。 还 可 以 输 入 一 个 正 则 表<br />
达 式 , 这 类 似 于 egrep 程 序 的 功 能 , 但 它 是 在 交 叉 索 引 数 据 库 中 查 找 , 速 度 要 快 得 多 。<br />
vim 提 供 了 一 些 选 项 可 以 调 整 它 的 cscope 功 能 :<br />
• cscopecscopeprg 选 项 用 于 设 置 cscope 程 序 的 位 置 。<br />
• cscopecscopequickfix 设 定 是 否 使 用 quickfix 窗 口 来 显 示 cscope 的 结 果 , 详 情 请 ":help<br />
cscopequickfix";<br />
• 如 果 你 想 vim 同 时 搜 索 tag 文 件 以 及 cscope 数 据 库 , 设 置 cscopecscopetag 选 项 ;<br />
• cscopecscopetagorder 选 项 决 定 是 先 查 找 tag 文 件 还 是 先 查 找 cscope 数 据 库 。 设 置 为 0 则 先 查 找<br />
cscope 数 据 库 , 设 置 为 1 先 查 找 tag 文 件 。 我 通 常 设 置 为 1, 因 为 在 tag 文 件 中 查 找 到 的 结 果 , 会<br />
把 最 佳 匹 配 列 在 第 一 位 。<br />
vim 的 手 册 中 给 出 了 使 用 cscope 的 建 议 方 法 , 使 用 命 令 ":help cscope-suggestions" 查 看 。<br />
下 面 是 我 的 vimrc 中 关 于 cscope 接 口 的 设 置 :<br />
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""<br />
" cscope setting<br />
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""<br />
if has("cscope")<br />
set csprg=/usr/bin/cscope<br />
set csto=1<br />
set cst<br />
set nocsverb<br />
" add any database in current directory<br />
if filereadable("cscope.out")<br />
cs add cscope.out<br />
endif<br />
set csverb<br />
endif<br />
nmap s :cs find s =expand("")<br />
nmap g :cs find g =expand("")<br />
nmap c :cs find c =expand("")<br />
nmap t :cs find t =expand("")<br />
nmap e :cs find e =expand("")<br />
nmap f :cs find f =expand("")<br />
nmap i :cs find i ^=expand("")$<br />
nmap d :cs find d =expand("")<br />
下 面 的 两 个 链 接 是 cscope 主 页 提 供 的 cscope 使 用 方 法 , 也 可 以 作 为 参 考 :<br />
vim/cscope 指 导 :http://cscope.sourceforge.net/cscope_vim_tutorial.html<br />
在 大 项 目 中 使 用 cscope:http://cscope.sourceforge.net/large_projects.html<br />
在 vim 的 网 站 上 有 很 多 与 cscope 相 关 的 插 件 , 有 兴 趣 可 以 去 看 一 下 。<br />
44