Get ctags in vim to go to definition, not declaration

前端 未结 10 2115
礼貌的吻别
礼貌的吻别 2020-12-07 15:25

I\'m having the problem that ctags in vim/gvim takes me to a forward declaration a lot of times instead of to the actual definition of the function.

Any way to get a

10条回答
  •  我在风中等你
    2020-12-07 16:24

    Late to the party, but for incoming vim tag googlers:

    I've found that using cscope in addition to ctags is the way to go, at least for C/C++. It's more intelligent about call trees, and you can set it to fallback to ctags if it fails. Just run "cscope -b" everytime you run ctags -R . and you'll be ready to go. If you use the settings below, you'll be able to use Ctrl-]/Ctrl-T like always, but you can also add nifty new jumps like jumping to a function declaration and showing a jumplist of function callers.

    " setup
    if has("cscope")
        set csto=0                                                                             
        set cst
        set nocsverb
        " add any database in current directory
        if filereadable("cscope.out")
        cs add cscope.out
        " else add database pointed to by environment
        elseif $CSCOPE_DB != ""
        cs add $CSCOPE_DB
        endif
        set csverb
    endif
    
    " jump to a function declaration
    nmap   :cs find s =expand("")1
    " show a list of where function is called
    nmap   :cs find c =expand("")
    

提交回复
热议问题