cscope 快捷键定义

来源:互联网 发布:python zip破解不好用 编辑:程序博客网 时间:2024/05/21 11:03


一直想在vim 中使用快捷键类似source insight  reference的功能, 但一直设置无效, 后来在网上找到方法,记录在此


http://blog.chinaunix.net/uid-16723279-id-3564805.html

有一个问题是敲 :cs find c closeAllVfds这太不人性了,函数名很长的情况下,要人命。快捷键映射就很重要了。

  1. nmap<leader>sa:csadd cscope.out<cr>
  2. nmap<leader>ss:cs find s<C-R>=expand("<cword>")<cr><cr>
  3. nmap<leader>sg:cs find g <C-R>=expand("<cword>")<cr><cr>
  4. nmap<leader>sc:cs find c <C-R>=expand("<cword>")<cr><cr>
  5. nmap<leader>st:cs find t <C-R>=expand("<cword>")<cr><cr>
  6. nmap<leader>se:cs find e <C-R>=expand("<cword>")<cr><cr>
  7. nmap<leader>sf:cs find f<C-R>=expand("<cfile>")<cr><cr>
  8. nmap<leader>si:cs find i<C-R>=expand("<cfile>")<cr><cr>
  9. nmap<leader>sd:cs find d <C-R>=expand("<cword>")<cr><cr>
    nmap表示在vim的普通模式下映射,当然相对与编辑模式和可视模式而言的,我们不多说。
    <C-R>=expand("cword")总体是为了得到:光标下的变量或函数。cword 表示:cursor word, 类似的还有:cfile表示光标所在处的文件名。
   
<header>这个键在我的vim中对应的是逗号 所以,上面的意思就 只要光标在我们关心的变量或者函数下,命令行模式敲,sc就相当与执行:cs find c 光标处函数名,注意,只需,sc三个键,不要敲冒号: 其他的键的映射也是类似的。    
    有了这个快捷键,我们使用cscope的效率就提升了,加上ctrl+]ctrl+o,ctrl+t 我们看项目代码基本就比较舒服了。

0 0