我刚刚在我的Vim(或者更确切地说是gVim)中安装了Ctags(以帮助c++开发),并希望找到您最喜欢的命令,宏,快捷方式,提示……

分享你最好的武器库。对于Vim开发中的c++,您还推荐哪些Vim附加组件?

编辑你还会用什么附加组件来配合Ctags?

你用什么版本的gVim和标签?有区别吗?

你如何提高你的编程经验,无论是大项目还是小项目?


当前回答

我调整了上面的SetTags()搜索函数(应该用等价的set tags+=./tags;/代替),以适用于cscope。似乎有用!

"cscope file-searching alternative
function SetCscope()
    let curdir = getcwd()

    while !filereadable("cscope.out") && getcwd() != "/"
            cd ..
                endwhile

    if filereadable("cscope.out")
            execute "cs add " . getcwd() . "/cscope.out"
                endif

    execute "cd " . curdir
    endfunction

call SetCscope()

其他回答

我调整了上面的SetTags()搜索函数(应该用等价的set tags+=./tags;/代替),以适用于cscope。似乎有用!

"cscope file-searching alternative
function SetCscope()
    let curdir = getcwd()

    while !filereadable("cscope.out") && getcwd() != "/"
            cd ..
                endwhile

    if filereadable("cscope.out")
            execute "cs add " . getcwd() . "/cscope.out"
                endif

    execute "cd " . curdir
    endfunction

call SetCscope()

我使用最多的命令是C-],它跳转到光标下的函数定义。你可以更经常地使用它来跟踪更多的电话。在那之后,C-o会带你回到一级,C-i会继续深入。

上面SetCscope()函数的另一个迭代。这将设置cscope预路径以获取匹配,而不位于“cscope. conf”所在的目录。”是:

function s:FindFile(file)
    let curdir = getcwd()
    let found = curdir
    while !filereadable(a:file) && found != "/"
        cd ..
        let found = getcwd()
    endwhile
    execute "cd " . curdir
    return found
endfunction

if has('cscope')    
    let $CSCOPE_DIR=s:FindFile("cscope.out")
    let $CSCOPE_DB=$CSCOPE_DIR."/cscope.out"
    if filereadable($CSCOPE_DB)
        cscope add $CSCOPE_DB $CSCOPE_DIR
    endif

    command -nargs=0 Cscope !cscope -ub -R &
endif

Ctrl+] -进入定义 Ctrl+T -从定义返回。 Ctrl+W Ctrl+] -以水平分割的方式打开定义

在vimrc中添加这些行 地图< C: \ >:标签分割< CR >: exec(“标签”.expand(“< cword >”))< CR > 地图< -)>:垂直地震剖面< CR >: exec(“标签”.expand(“< cword >”))< CR >

Ctrl+\ -在新选项卡中打开定义 Alt+] -以垂直分割的方式打开定义

标签生成完成后。您可以使用以下键标记进入和标记出函数:

Ctrl+鼠标左键-转到定义 Ctrl+鼠标右键-从定义跳回

以上所有的……

Code_complete:函数参数完成、代码片段等等。

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

标记列表。vim:源代码浏览器(支持C/ c++, java, perl, python, tcl, sql, php等)

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