如何在vim中自动加载cscope.out [英] how to auto load cscope.out in vim

查看:10
本文介绍了如何在vim中自动加载cscope.out的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的项目的子目录中自动加载我的cscope.out,所以我在我的.vimrc中添加了这个脚本,如下:

I want to auto load my cscope.out in the subdirectory of my project, so I add this scripts in my .vimrc, which is as follows:

set cscopequickfix=s-,c-,d-,i-,t-,e-

if has("cscope")
    set csprg=/usr/bin/cscope
    set csto=1
    set cst
    set csverb
    set cspc=3
    "add any database in current dir
    if filereadable("cscope.out")
        cs add cscope.out
    "else search cscope.out elsewhere
    else
       let cscope_file=findfile("cscope.out", ".;")
        "echo cscope_file
        if !empty(cscope_file) && filereadable(cscope_file)
            exe "cs add" cscope_file
        endif      
     endif
endif

它首先起作用.但是每次当我尝试这样做时:

it works at first. But every time when I trying to do:

:cs find c [tag]  

搜索结果将出现在 QuickFix 列表中,但无法打开包含该结果的文件.

The search result will appear in the QuickFix List, but the file which contains the result can not be opened.

任何建议将不胜感激.

推荐答案

如果你添加一个 cscope.out 确保它设置了正确的路径前缀.否则它会显示结果但无法加载文件.

If you add a cscope.out make sure it to set the correct path prefix. Otherwise it will show you the result but cannot load the file.

示例:

   cs add ../cscope.out ../

所以你应该把你的脚本改成

so you should change your script to

 ...
 else
   let cscope_file=findfile("cscope.out", ".;")
   let cscope_pre=matchstr(cscope_file, ".*/")
   "echo cscope_file
   if !empty(cscope_file) && filereadable(cscope_file)
      exe "cs add" cscope_file cscope_pre
   endif
 ...

这篇关于如何在vim中自动加载cscope.out的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆